Game Maker Tips: pause and frame by frame test


Just a quick tip for the users of Game Maker (but the idea can be implemented anywhere I guess): how to test your project and skip the frames one by one.

I’ll just post the content of the script, copy and paste it in one object only. Then add the second script in any object you want to be able to freeze and frameskip.

Declare the following global variables:

  • frameskip
  • pause

First script:

//Pause and frameskip function
if (gamepad_button_check_pressed(0, gp_start)) or (global.frameskip < 0)
if (global.game_paused = false)
global.game_paused = true;
global.frameskip = 0;
else global.game_paused = false;

if (global.game_paused) and (gamepad_button_check_pressed(0, gp_shoulderr))
global.frameskip = 1;

if (global.frameskip > 0)
global.game_paused = false;
global.frameskip = -1;

Second script:

//Pause function, cancel event
if (global.game_paused) exit;

Here is an example of it being used in my project:

Well this assist to get inside shafts while sliding doesn’t work 🙁

Happy coding!

– Skaz

One Reply to “Game Maker Tips: pause and frame by frame test”

  1. An explanation would be great. It could help many people understand how it works.

    Here’s a simple explanation for anyone who might want one:

    When the “Start” button is pressed on the controller, the pause variable is turned to true. This way, through the second script, the event would exit, pausing the object’s movements and functions. (Yes, it needs to be put at the TOP of the Step event of the objects).

    If the game is paused and the R button is pressed, it will turn the frameskip variable to 1, which will lead to the game being resumed (pause becoming false). This will make the frameskip variable -1, which will pause the game the next step. So this way, if you pause the game with Start, you can run the game for one step by pressing R.

Leave a Reply

Your email address will not be published. Required fields are marked *