The goal of this game is to get our character to catch the star without touching the edge of the stage.
This game is a little like a platformer. The more stars we catch the more levels we go through.
I’ve made two custom sprites, the first is the ‘You Lost’ sprite and the second is the Level. I’ve made two costumes that will form the levels:
Make Our Cat Stand on the Level
To make our cat stand on our level, we are going to need to add some special colour to the cat costumes, look at this zoom-in view of our cat’s feet:
I’ve added some red dots so that we can use some code to make our code easier.
Now we want to make sure that our cat starts in the correct location:
I also made sure the backdrop is correctly set and that my cat will rotate correctly.
Now we need a way to make our cat fall from the sky always, we are going to create a new variable called ‘YSpeed’.
We always want to make this number decrease, this will act like gravity.
We also make sure that Scratch the cat is at the front of the screen.
If scratch is touching our level blocks, then we want to make sure that the gravity doesn’t have any effect.
Be sure to use the colour of the dots we added to Scratch the cat to the first part of the colour test, then use the colour of the level blocks. We will set our variable to 1 if we are standing on the level.
Next we can add some left and right movement checks for our keypress events.
Finally we can add the jumping code and the code that will change our y position.
The full code for our character sprite is above.
Losing If We Touch The Edge
If we touch the edge of the screen we want to automatically loose.
On our Scratch the cat sprite, add another check to our forever loop:
We created a new broadcast message called ‘Lost’. This will tell our sprite that it is time to be seen.
On our ‘You Lost’ Sprite we can have the following code:
Moving to the Next Level
If our character touches the star sprite, then we want to change the level sprite to the next costume, On the start sprite:
We pick a random location and broadcast a ‘NewLevel’ event.
The Level sprite will respond by changing the level.
Add variables to keep track of how many stars you catch.