012. ONE GAME A MONTH (DEV LOG #8)

I brushed up on timelines when working on the tutorial that will be in my game. Timelines are simple once you understand the big picture.

WTF are steps?

In GameMaker, we have this concept of “steps” (others might call them ticks or updates). A step is the smallest unit of time that your game is using. All of your code in your “step” events will run during each step.

How many steps can you have? You decide. Games that are 60 fps have 60 steps every second. The more steps you have, the smoother everything should run (in theory).

Steps and Timelines; what’s the deal?

So we know how to drag and drop code into the Step. This code will be called every step of the game (if your game is at 30 fps, the code in your Step event will run 30 times a second). It’s not very flexible; what if I have an enemy that I want to start walking when the game is at 69 (hehe) steps? You could set up a timer to count up the amount of steps that went by, but this gets complicated when you want to create complex events. This is where Timelines come in.

Credits to Adele

Credits to Adele

A Timeline is like the status bar that shows your time remaining in iTunes. Let’s say you wanted your character to start moving left at the 10 step mark, you would go to the 10 step mark and add the code there. If you wanted the character to start moving down at the 30 step mark, add the code at the 30 step mark. When you’re done creating all of the events, you can hit play (run your Timeline) and admire your character moving all over the place, just as you planned it.

In my tutorial, the player walks into the room, and text pops up showing you how to move him. Then the cloud character comes into the window and more text comes up, telling you how you can move him. Lastly, an enemy comes and you are shown how to kill him. There are pauses in between each of these events (which Timeline does perfectly), and the results are exactly as I wanted it.

These are the main timeline variables that you will need.

  1. timeline_index             – this is the timeline that you will be working with. Set it to the name of the timeline that you have created in GameMaker (or if you’re a bad ass that created their own dynamic timeline. Good job, showoff.)
  2. timeline_running         – when you want your timeline to actually play, set this variable to true
  3. timeline_loop              – if you want your timeline to repeat, set this to true. You might need this if you have an enemy that patrols. The enemy can start walking left, then at 60 steps, start walking down, then start walking right at 120 steps, and up at 180 steps. Set “timeline_loop” equal to true to have the enemy patrol forever

Timelines are a strong feature of GameMaker. Take advantage of it, rather than using long-winded if-statements and alarms. Work smart, not hard.