(For)ever loop
Quote:Original post by Antheus
Personally, the only place I've found use for infinite loops recently were threads.
*** Source Snippet Removed ***
same actually, though i suppose any C++ game really needs a while(true) loop to process the game...though i don't like the whole for(;;) notation, especially since theres not a nice way to break the loop...whats wrong with
bool gameRunning = true;
while(gameRunning)
{
//render, physics, ai, game logic, whatever!
if(endGameRunningCondition == true) gameRunning = false;
}
Quote:Original post by WinegumsQuote:Original post by Antheus
Personally, the only place I've found use for infinite loops recently were threads.
*** Source Snippet Removed ***
same actually, though i suppose any C++ game really needs a while(true) loop to process the game...though i don't like the whole for(;;) notation, especially since theres not a nice way to break the loop...whats wrong with
bool gameRunning = true;
while(gameRunning)
{
//render, physics, ai, game logic, whatever!
if(endGameRunningCondition == true) gameRunning = false;
}
while ( !endGameRunningCondition ) { //}
Quote:Original post by jjd
This thread has made baby Jesus cry.
for (;;) { Jesus::Baby->getInstance()->cry();}
Here, let me add a singleton for more tears.
Quote:Original post by Antheusfor (;;) { Jesus::Baby->getInstance()->cry();}
Here, let me add a singleton for more tears.
Oy vey.
Quote:Original post by Antheus
while ( !endGameRunningCondition ) { //}
Thank you for posting the only "infinite" loop I have ever used in any program. Although I usually use "done" in place of "endGameRunningCondition."
All loops have a terminating condition.
This thread is quite funny. I might post a mini noob tutorial of my own.
[Edited by - ForeverNoobie on June 4, 2007 9:04:29 PM]
[Edited by - ForeverNoobie on June 4, 2007 9:04:29 PM]
[EDIT}
I was laughing at this thread, until I remembered how much it shits me when arrogance overtakes courtesy on these forums... Laughing at this horrible, horrible "tutorial" is just gonna create one more person in the world who thinks gamedev.net is full of jerks, so the least we should do is point out why his code is wrong...
Original post by PhoenixAdmin + comments
I.E. the above code is exactly the same as the code below:
[Edited by - Hodgman on June 6, 2007 8:24:48 PM]
I was laughing at this thread, until I remembered how much it shits me when arrogance overtakes courtesy on these forums... Laughing at this horrible, horrible "tutorial" is just gonna create one more person in the world who thinks gamedev.net is full of jerks, so the least we should do is point out why his code is wrong...
Original post by PhoenixAdmin + comments
for(;;)//start "infinite" loop{ while(condition){//start normal loop do something continue;//go back to the top of the while loop }//without the above continue, it would go back to the top anyway... break;//ensure "infinite" loop only runs once (its not a loop at all!)}
I.E. the above code is exactly the same as the code below:
while(condition){ do something}
[Edited by - Hodgman on June 6, 2007 8:24:48 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement