The "Do" Statement

Here you can learn about the "do" statement.

A "do" is really the "do... until" statement as you cannot have one without the other. It has this form:

do <statement> until (<expression>)

The statement (which can also be a code block) is executed until the expression is found true, and the initial statement is always executed at least once. Be careful with your do loops, as you can easily make them loop forever, in which case your game will hang and not react to any user input anymore. Below you can find an example of a typical way to use "do... until":

   x = random(room_width);
   y = random(room_height);
until (place_free(x, y)); }

The above 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).

Back: GML Overview
Next: The "For" Statement
© Copyright YoYo Games Ltd. 2018 All Rights Reserved