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.

Next you specify the end behavior, that is, what should happen when the end of the path is<br />

reached. You can choose to stop the motion and end the path. You can also restart the path<br />

from the beginning, that is, the instance jumps back to the position where the path was<br />

started and executes the path again. A third option is to restart from the current position, that<br />

is, the instance follows the path again but now <strong>with</strong> this new starting position (this is the same<br />

when the path is closed). Finally you can choose to reverse the motion, making the instance<br />

go back and forth along the path. Note that also at the end of the path an event happens; see<br />

below.<br />

Finally you can indicate whether the path must be absolute or relative. An absolute path is<br />

executed at the place where it is defined. The instance is placed at the start position and<br />

moved from there (end position when speed is negative). This is, for example, useful when<br />

you have a race track on which you have defined the path. When you choose relative the<br />

instances starts executing the path from its current position. This is useful when an instance<br />

should make a local motion. For example, space ships in a space invader game can make a<br />

particular turn from their current position.<br />

When you want to place the instance at a different point along its path you can use the action<br />

to set the path position. A path position always lies between 0 and 1, 0 indicating the start<br />

position and 1 the end position on the path. Note that in each step the direction variable is<br />

automatically set to the correct direction along the path. You can use this variable to choose<br />

the correct orientation for the sprite.<br />

When using scripts or pieces of code you have more control over the way the path is<br />

executed. There is a function to start a path for an instance. The variable path_position<br />

indicates the current position on the path (between 0 and 1 as indicated above). The variable<br />

path_speed indicates the speed along the path. A variable path_scale can be used to scale<br />

the path. A value of 1 is the original size. A larger value indicates that the path is made larger;<br />

a smaller value makes it smaller. The variable path_orientation indicates the orientation<br />

in which the path is executed (in degrees counter-clockwise). This enables you to execute the<br />

path in a different orientation (e.g. moving up and down rather than left and right). There is<br />

also a variable to control the end behavior. Finally there are lots of functions to ask for<br />

properties of paths (e.g. the x and y coordinate at a certain positions) and there are functions<br />

to create paths. There are even functions that create collision free paths for an instance to<br />

reach a certain goal. See the later sections on GML for details on this.

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

Saved successfully!

Ooh no, something went wrong!