(For)ever loop

Started by
50 comments, last by Crypter 16 years, 10 months ago
Am completely aware of what abort(); yes its bad.
Advertisement
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 Winegums
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;
}


while ( !endGameRunningCondition ) {  //}
This thread has made baby Jesus cry.

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

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 Antheus
for (;;) {  Jesus::Baby->getInstance()->cry();}


Here, let me add a singleton for more tears.


Oy vey.

There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
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.
Programming since 1995.
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]
Simplicity is the ultimate sophistication. – Leonardo da Vinci
[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
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]
Why don't you just return out of it any way. hmm

This topic is closed to new replies.

Advertisement