Different things a game programmer has to think about:
- Give the player feedback when collecting points or achieving a rank
- Where to put the scoreboard and other various information like health bars, etc..
Let's take the well known Ghost Shooter game from the Beginner's tutorial and add on some extras concerning scoring.
What we want to do now:
- killing a monster gives the player 10 points (instead of originally 1)
- when a monster gets killed, the score point is faded and animated directly above the monster's position
Adapt monster object
Click on a monster object in the Layout window and add a new instance variable monsterScore and give it an initial value of 10
Whenever the player kills a monster, 10 points are added to the score.
Give player feedback of the monster's point value
Be sure the Layer Main is active and double-click somewhere outside of the Layout.
Create a new Text object (not Text box object!), name it displayScoreOnObject
Let's give it two behaviors Fade and Bullet
As shown in the above image, I also changed the font to Impact, with a size of 22 and a greenish color, plus a few different properties.
In the Event sheet, go to the event Monster -> Health <0 and insert the following actions as the topmost.
Add an action System -> Create Object -> Text object displayScoreOnObject -> on layer 1 at the coordinates Monster.X and Monster.Y
Add another action below displayScoreOnObject -> Set text -> Monster.monsterScore
In the original game, score gets an additional point. Now it adds up the value of the variable monsterScore which is 10.
Whenever the player kills a monster, the text object fades in with the point value of the monster and fades away.
I'll work on another tutorial by adding some features like a health bar. The idea is to reduce the player's health when monsters touch him/her. Every x seconds the player's health rises again and we could add an emergency kit box ;-) for the player to fill his health points.