Question on Do\While
Started by Felthorn, Feb 15 2013 12:15 AM
2 replies to this topic
#1
Posted 15 February 2013 - 12:15 AM
Hey, I have a (probably really stupid and noobish ) question. Do I need to have a condition for a do\while statment. I've change my game so that it is far simpler, and right now I'm trying to make a room with two doors in it, and I want the game to ask you which door you want to use every time you enter the main room. Any help will be greatly appreciated. Thanks!
#2
Posted 15 February 2013 - 07:22 AM
You do need to have a condition, but if you want an infinite loop then you can just use "true" as the condition, as in "do { ... } while (true);".
Actually, most programmers would write an infinite loop as "while (true) { ... }" or "for (;
{ ... }", but the do-while form will work as well.
Actually, most programmers would write an infinite loop as "while (true) { ... }" or "for (;
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 15 February 2013 - 09:07 AM
watch out for your while loops, if the condition never meets you go on an infinite cycle. preferably leave them out of the code unless you have to.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











