We have learned how to program the game Apple Excitement, Animal Racing with Scratch. Next, let's also learn how to program the game Cat Chasing Mouse.
How to program the game Cat and Mouse
Right from the name Cat Chasing Mouse, you can understand the structure of this game. So let's start programming this game.
Step 1: Choose a wallpaper for the game
To make the game interesting, the first thing to do is choose the background. You can choose the rat-tailed cat scene in the house, yard, beach… by clicking Choose a background in the bottom right corner.
Step 2: Set up characters for the game
This is a game called Cat and Mouse, so of course we will need two characters, Cat and Mouse. Access the item Add characters in Character frame to choose 2 cat and mouse characters according to your preferences.
Don't forget to delete the default character if you don't want to use it by clicking the trash icon next to the character.
Step 3: Program the Cat character
We need to set it up so that the cat moves flexibly according to our control, thereby quickly catching the mouse. The programming steps for the cat will be as follows:
- Drag the code When clicking on the green flag of item Event Go to programming section.
- Select code Continuous in section Control.
- More Go to the mouse pointer of section Move.
- Facing towards the object (_) in Motion. Part (_) Select the object as the mouse.
Step 4: Program the Mouse character
In order for the mouse to run everywhere and hide from the cat, you will need to program it as follows:
- Pull code When clicking on the green flag of item Event into the programming interface.
- More Continuous belongs to section Control enter.
- In section Movemore Surf for (_) seconds to random location. UMBRELLA (_) you should install it 1 Let the mouse move at a moderate level.
- Finally add Turn it back on if it touches the edge also belongs to the section Move.
To make the game more vivid, you can add sound to the mouse every time it is caught by a cat by programming as follows:
- Add code If (_) then as a subfile of the code Continuous. In (_) additional code Touching (_) and choose cat character.
- Insert code Start sound (_) belongs to section Sound. Part (_) You can set the sound to suit the mouse when caught by the cat.
In addition, you can also install it so that every time it is caught, the mouse will disappear and reappear in a different location.
- Drag the item Hide in Show as a subfile of the code If (_) then.
- Insert additional code Go to random location belong Move down below.
- Add code Wait (_) seconds belongs to section Control. In part (_) You can set the number of seconds to wait for the mouse to reappear in the game interface.
- Finally, insert more code Presently belongs to section Show.
Step 5: Publish the game Cat Chasing Mouse
After completing all of the above steps, you have finished programming the Cat Chasing Mouse game. You can refer to the game programming code set that Quantrimang has made below and edit and supplement according to your preferences.
Programming code for Mouse
Programming code for Cats
Finally, you just need to publish the game you just programmed. Please press it See the Projects page in the toolbar at the top of the screen to save the game as well as start the game experience process.
At the interface you just navigated to, press the green flag button to start trying out the game you just programmed.
Above are all detailed instructions Programming the game Cat and Mouse with Scratch that Quantrimang wants to introduce to you. Wishing you success in programming and experiencing this game.