Designing Games with GameMaker
While statement
A while statement has the form
while (<expression>) <statement>
As long as the expression is true, the statement (which can also be a block) is executed. Be careful with your while loops. You can easily make them loop forever, in which case your game will hang and not react to any user input anymore.
Example
The following program tries to place the current object at a free position
(this is about the same as the action to move an object to a random
position).
{ while (!place_free(x,y)) { x = random(room_width); y = random(room_height); } }
« Repeat statement | Do statement »
Alternative versions
You can also read this manual on one single long page (± 1.5 mb)
Also available in:
Download helpfile
Also available in:
Download helpfile