“Quick” Tips for Gamemaker (Part 3- Score)


So, in the last gamemaker tip, we covered movement for your character.  In this post, we will cover adding a score to your game.  Obviously, having a score is a necessary way to keep your users interested in playing.  I mean what’s the point of playing a game if I can’t know if I beat my friends or not?!  So we agree, having a score is necessary!

Therefore, let’s get started.  In general, there are lot of different ways to keep scores.  For example, in a shooter, the user might earn ten points every time he shoots down a spaceship or an alien.  In today’s tutorial, we cover how to increase score as time increases.  To see an example of this, you can check out either of my two Windows 8 games, Quick Surf and Rain Dodge.  In these kinds of games, the player’s score increases the longer he survives.

The basic idea behind this type of scoring system is to use an “alarm”.  An alarm can be created and started, and when it expires, it can execute some kind of action.  In this case, that action is increasing the score.  So how do we do this? 

Let’s start by initializing the alarm.  We can do this under the “Create” event for the main character of your game.  In my example, that character is called  “obj_boy”.  So, add the “create” event here, and then for the action, click on the “main 2” tab, and choose “set alarm”, located in the top left (shown below).

alarm1_capt

In the pop up box, you will be able to choose the duration of your alarm in terms of steps.  15 steps is equal to one second, so 30 steps is two seconds, etc.  I am choosing to increase my score every second the player survives, so I will use 15 steps as below.  Notice also that you can choose which alarm (Alarm 0, Alarm 1, etc.) you want to use.  It doesn’t really matter which one you choose, but make sure you remember it.  For me, I am using Alarm 0.

alarm2_capt

What we have done so far is basically start an alarm that will last for 1 second (15 steps).  So, how do we tell it what to do when it expires?  For that we need to add the Event for our alarm, which in my case is Alarm 0.  Go to add event->Alarm and choose the alarm that you are working with.  In the action for this event, we are going to increase the player’s score by 1.  We can go under the “score” tab, and choose the “set score” action, shown below.

score_capt

In the pop up box, we set “new score” to 1 and check the “relative” box as shown below to ensure that we are increasing the already existing score.

score2_capt

We also need to restart our alarm here, so that we continually add a point for each second that passes.  We need to add the “set alarm” action here exactly as we did before, using 15 steps as our counter.  This will recursively increase the players score as time continues on.  Your Alarm 0 event should therefore look like this.

alarm3_capt

The last thing we need to do is to display the score. This can be achieved by adding a draw event, add event->Draw->Draw.  Inside of this event, we want to add the “Draw Score” action which is located to the far right of the “Set Score” action.  You can change the X and Y coordinates here, to specify where exactly to draw the score.  I just use (0,0), which is the top left corner.  You can also change the “caption” if you choose, but “Score:” works for me.  Should look like this.

score3_capt

If you save and run your game at this point, you should see your score increasing by 1 every second :).  Keep up with my blog for more gamemaker tips!  As always, comment with any questions, feedback, etc.


Comments (1)

  1. Troy says:

    And how do you make a high score table(local)? thank you

Skip to main content