Creating a Score in GameMaker
- Create a score object , called it objScore
- Add a Create event to the object and setup a global variable to store the score:
global.pscore = 0;
- Add a Draw event to this object to draw the score to the screen
//draws the score in the top left corner draw_text(40, 20, "Score: " + string(global.pscore));
- 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:
- 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);
- 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.