O'Reilly logo

GameMaker Game Programming with GML by Matthew DeLucas

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

Dying from hazards

Previously, pickups that help increase score and vitality were constructed, but nothing has been made that can actually cause Vlad harm. In this section, a simple hazard will be created. Then, a script will be written that will cause the player to "die" when they fall off the bottom of the screen.

Establishing a death state

Before creating any hazards, a new state should be created for Vlad: the death state. This will run when Vlad's health is set to a value less than or equal to 0 or if he falls below a specified value in the room.

A user-defined constant should first be created. In this instance, the constant will be named state_death and set to a value of 3. This is so that User Defined 3 will be launched during the Step event ...

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