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.

<strong>Game</strong> <strong>Maker</strong> contains a built-in programming language. This programming language gives you<br />

much more flexibility and control than the standard actions. This language we will refer to as<br />

GML (the <strong>Game</strong> <strong>Maker</strong> Language). There are a number of different places where you can type<br />

programs in this language. First of all, when you define scripts. A script is a program in GML.<br />

Secondly, when you add a code action to an event. In a code action you again have to provide<br />

a program in GML. Thirdly, in the room creation code. And finally, wherever you need to<br />

specify a value in an action, you can also use an expression in GML. An expression, as we will<br />

see below is not a complete program, but a piece of code resulting in a value.<br />

In this chapter we will describe the basic structure of programs in GML. When you want to use<br />

programs in GML, there are a couple of things you have to be careful about. First of all, for all<br />

your resources (sprites, objects, sounds, etc.) you must use names that start <strong>with</strong> a letter and<br />

only consist of letters, digits and the underscore '_' symbol. Otherwise you cannot refer to<br />

them from <strong>with</strong>in the program. Make sure all resources have different names. Also be careful<br />

not to name resources self, other, global, or all because these have special meaning in the<br />

language. Also you should not use any of the keywords, indicated below.<br />

A program<br />

A program consists of a set of instructions, called statements. A program must start <strong>with</strong> the<br />

symbol '{' and end <strong>with</strong> the symbol '}'. Between these symbols there are the statements.<br />

Statements must be separated <strong>with</strong> a ';' symbol. So the global structure of every program is:<br />

{<br />

}<br />

;<br />

;<br />

...<br />

There are a number of different types of statements, which will be discussed below.<br />

Variables<br />

Like any programming language GML contains variables. Variables are memory locations that<br />

store information. They have a name so that you can refer to them. A variable in GML can

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

Saved successfully!

Ooh no, something went wrong!