In this lesson, we create a variable called score and update it when a collision occurs. The code occurs in our “Play game” broadcast while moving the ship.
We add the following code:

So that the code becomes:

We add a variable called Still playing to keep track of our current game state:

And the score is only reset during initialization when “StillPlaying” is false.

In the case that the ship is missed after movement was completed,, we simply set “StillPlaying” to false and our score is reset during initialization:

That’s it for our main logic!
Here’s the full code for the spaceship:


Here’s the code for the planet:

A full implementation with all the bells and whistles can be found here:
© 2019 Vedesh Kungebeharry. All rights reserved.
[…] Next: A Simple Game! – Part 5 […]
LikeLike