08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

obj[1].id.x = 12;<br />

The last statement should be read as follows. We take the id of the first flag. For the instance<br />

<strong>with</strong> that id we set the x coordinate to 12.<br />

Object names, the special objects, and the instance id's can also be used in a number of<br />

functions. They are actually treated as constants in the programs.<br />

Arrays<br />

You can use 1- and 2-dimensional arrays in GML. Simply put the index between square<br />

brackets for a 1-dimensional array, and the two indices <strong>with</strong> a comma between them for 2-<br />

dimensional arrays. At the moment you use an index the array is generated. Each array runs<br />

from index 0. So be careful <strong>with</strong> using large indices because memory for a large array will be<br />

reserved. Never use negative indices. The system puts a limit of 32000 on each index and<br />

1000000 on the total size. So for example you can write the following:<br />

{<br />

}<br />

a[0] = 1;<br />

i = 1;<br />

while (i < 10) { a[i] = 2*a[i-1]; i += 1;}<br />

b[4,6] = 32;<br />

If statement<br />

An if statement has the form<br />

or<br />

if () <br />

if () else

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!