#Gamedev Tutorials

How to Create a Regressive Counter in GameMaker Studio

A step-by-step tutorial

Share
FavoriteLoadingAdd to favorites

Hello, guys! All right with you? Today we will learn how to create a Regressive Counter in GameMaker Studio.

Follow the steps below:

1. Create an object with the name "obj_contador" and add the following events:

GameMaker Studio

2. In the Create event, click the Control Tab and drag the "Execute Code" option to the Actions window. Enter the code below and click the visa to save. 

tempo = 60;

alarm [0] = 10;

GameMaker Studio

NOTE: Here we define the time variable equal to 60. And we will have to wait for 10 steps to activate the alarm [0].

3. Now in Event Alarm 0, drag the "Execute Code" option back into the Actions window. Enter the following code and click on the visa to save. 

tempo - = 1;

if (tempo == 0) {

game_end ();

tempo = 60;}

alarm [0] = 10;

GameMaker Studio

NOTE: In this code, a condition was created for the time variable. The time will decrease at every 1 second. And if time equals zero, then it's the end of the game. The game window will close automatically.

4. And finally, in the Draw Event GUI, drag the "Execute Code" option again to the Actions window. Enter the following code and click on the visa to save.

draw_text (650.52, tempo);

GameMaker Studio

NOTE: This is code that will show the time variable in the game window.

5. Now, create a Room, then click on the Aba Objects and place the "obj_contador" inside the Room. Then click on the visa to save the changes.

GameMaker Studio

6. Press F5 to start your Project. The final result will be as in the figure below:

GameMaker Studio

Example of Regressive Counter

Before beginning to practice GameMaker, watch the following video (in Portuguese) that shows the final result of a Regressive Counter and its use within Super Mario Bros game.

That's it! Hope this helps! Hit subscribe on my channel to watch and follow the upcoming GameMaker video lessons. I hope you enjoy and share this with your friends.

Any questions, just leave a comment below. Suggestions for lessons or Tutorials are always welcome. ^^

Good studies and have fun!

A big hug.

 

Join us!


How about writing your own piece for IndieWatch?


Tags
#2dgame #gamedev #indiedev #tutorial #games #mario #IndieGameDev GameMaker Studio #gamemaker

Leave a Reply

Your email address will not be published.

Back to top button
Close