Our first step to add a score to our program is to reopen our project from yesterday. We need to work with the Ball object, so we will double click on the ball object.
Now on the far right there is a tab for score. Selecting the score tab makes the objects that work with the score available.
Now we see the score objects that can be added as actions to the events. We want to add be have the create event for ObjBall selected and then drag the score icon to the actions….
We will leave everything set as is for this and just choose ok. (Setting it to score 0 and relative not checked. – Thus starting our score at 0) Next we want to add the action to display the score on the screen. This is under Health in the icons.
Display a Score Caption
There are several options here which for now we will leave as is. You can see the show score is set to score, caption to score: and don’t show health or lives. Choose OK to leave the Defaults. Now our Ball Object Create Event should look like:
Now we want the score to change each time a Barrier is destroyed. So we will select the Collision with Barrier Event:
To add to the score we will add the Set Score icon to the Action for Collision with Barrier. In this case we want to add one point for each time a barrier is destroyed. So we will set new score to 1. To define that the score should add 1 as opposed to set the score to 1 each time we will check the relative box. Without checking the box the value will change to 1 with the first barrier being destroyed and stay that way. With relative checked the score will be current score + 1.
Now our Collision with Barrier on Obj Ball should look like:
Finally click OK and we are ready to play!
To share your game with friends choose the create executable under the file tab….
If you plan to send your game to your friends through email you will need to zip the file first as most email programs won’t send or receive .exe files. We’ll look at making more changes to our program next week.
Subscribe To Our Newsletter
Thank you! Sign up for my newsletter to receive periodic news, updates, and more. As a special thank you, you will receive a free copy of our Programming the Game Break Out Tutorial. I look forward to connecting with you!
Excellent info! I have already been searching for something such as this for a time now. Appreciation!