Games in Scratch: Catch the Mouse
There are many games in Scratch coding that you kids can develop. But, Catch the mouse, a simple yet interesting game for beginners on scratch programming. This game depicts the never ending rivalry among cat and mouse.
In this game we have two main characters i.e. cat and a mouse as our sprites.
Mouse is humanly controlled and moves in direction of mouse pointer whereas cat always tries to catch the mouse by chasing it. To make it more appealing we add cheese the favorite food of mouse as sprites as well.
So, our overall game looks like;
Mouse: is controlled by human through mouse pointer.
Cat: keeps on chasing the mouse and if chased life is decreased.
Cheese: mouse tries to eat cheese and this increases score.
Life: Mouse has three lives.
Score: Mouse has to get 10 cheeses to make score equal to 10 for winning the game.
A Game Plane for Cat and Mouse
Let’s quickly jot down our key requirements for catch the mouse game.
- Create or select backdrop
- Create or select cat from sprite library
- Select mouse from library
- Create cheese or select any food of your choice.
- Create you win sprite
- Create Game over sprite
- Create variables of life and score.
⇒ Ping Pong Game ⇐
Selecting a backdrop
Choose a simple and plain backdrop from library or create your own from built in paint on scratch. Here I am creating my own plain background. Click on the paint brush and start creating.
Here, I am using a simple grey color background made by a centre filled rectangle. Check the image for better understanding.
Our backdrop is ready.
Let’s create all of our required sprites at once by clicking on paint brush then we will proceed to coding.
Making of cat
I have made by own cat simply by joining two circles and ears by joining two lines or you may select from library.
Select a mouse from sprite library.
Again click on paint and draw triangle cheese or select any food from the sprite library. I have made my own cheese.
Make You Win sprite by clicking on paint, select text and write You Win.
Make Game Over sprite by clicking on paint, select text and write Game Over.
Go to data & blocks. Create variables of life and score by clicking on create variables and name them as life and score.
Let’s start putting lives to our sprites.
Code the Cat
We want our cat to start from a specific point and keep on chasing mouse throughout the game whenever the green flag is clicked.
Drag whenever green flag is clicked to the scripting area and select go to block and specify the location for the starting point of cat. Now, code the cat to move 2 steps in direction of mouse forever.
Code the Mouse
We want our mouse to run away from cat in the direction of our mouse pointer.
Drag whenever green flag is clicked to the scripting area and select go to block and specify the location for the starting point of mouse. Now, code the mouse to move 5 steps in direction of mouse pointer forever.
Coding the Cheese
We want cheese (food) to be hidden initially and show up after 1 second. Once showed, if the mouse touches the cheese it will hide for 1 second and keep on appearing at random stage point always.
Cheese is named as sprite 2.
This is the coding of first
Cheese Sprite 2
Create duplicate of cheese sprite by right clicking on sprite 1 and create two copies.
Codding remains the same for all just change the waiting time for showing up the cheese.
Cheese sprite 3
Cheese Sprite 4
Coding for Variable
We will set life as 3 at the start of the game and Score as zero whenever game starts.
Variable of life
Life should change by negative one whenever cat touches the mouse.
Create if condition in cat sprite that if cat touches the mouse life should decrease by 1 and make sure to add wait command otherwise life keeps on decreasing. And place it under forever loop just below move 2 step block.
*note: use correct sprite names.
Variable of Score
Score should change by positive 1 whenever mouse sprite touches cheese sprites.
Create three if conditions in mouse sprites that if the mouse touches sprite1, sprite2 or sprite3 the score should change by positive 1. And place them under forever loop just below move 5 steps block.
CODING FOR YOU WIN
You win should appear as the score is equal to 10 otherwise it should remain hidden.
Create one if condition that if the score is equal to 10 you win should appear and everything should stop.
CODING FOR GAME OVER
Game Over should appear as the life is equal to 0 otherwise it should remain hidden.
Create one if condition that if the Life is equal to 0 Game Over should appear and everything should stop.
COMPLETE CODING to Develop Catch the Mouse Games in Scratch