O'Reilly logo

GameMaker Essentials by Nathan Auckett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Statements and loops

In nearly every programming language, there is the option to use statements such as if and else. Often, we need to use loops such as the for loop. Statements and loops make a programmer's life much easier when it comes to keeping code readable and organized, so let's take a look at how these look in GML.

Loops allow developers to greatly reduce the amount of code needed to execute a repetitive task. Instead of using multiple if statements, the programmer can summarize it all into a single loop, keeping the code short and concise.

Statements

First, we will look at the simpler of the two statements. We will begin with the most commonly used statement, the if statement.

The if statement

The if statement allows us to ask our game ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required