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

Starting Vlad's events and scripts – walking

For the walk state of obj_vlad, the player will use the left and right keyboard arrows to move the character. To accomplish this, scripts will be written into the following events:

  • The Create event
  • The Step event
  • The User Defined 0 event
  • The User-Defined 1 event

The Create event

Similar to most Create events, the Create event of obj_vlad will handle defining important instanced variables. The following code assigns values to each of these variables that we need to go from the idle state to the walking state and vice versa:

/// Variable initialization for character // The state of the character used within the update state. state_id = state_idle; // Has the player entered a new state. entered_new_state = false; ...

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