Adding a score to your game

computer game score

Creating a Score in Game Maker Studio 2

  1. Create a score object , called it objScore
  2. Add a Create event to the object and setup a global variable to store the score:
    global.pscore = 0;
  3. Add a Draw event to this object to draw the score to the screen
    //draws the score in the top left corner
    draw_text(20, 10, "Score: " + string(global.pscore));
  4. Open your enemy object.On the collision event with your player laser or wherever you have checked that the enemies health has reached zero add the following code, inside the if condition:
    global.pscore += 1;

    Your code will end up looking something like this:

    Text Description automatically generated

  5. If you want something to happen when you score reaches a certain size, on the player object Step Step event you could add something like this code:
    if global.pscore=10 //when score reaches 10 end the game
    
    room_goto(EndRoom1);
  6. Add the score object to your game room

Additional Resource:

Here is an old video that shows you how you can set your font type and colors in Game Maker. Use these functions inside the Draw event.

Tomas
Latest posts by Tomas (see all)

Leave a Comment

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

Scroll to Top