This post was originally posted on: https://theedvolution.com/games-in-scratch-catch-the-mouse/

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 between cat and mouse.
In this game, we have two main characters i.e. cat and a mouse as our sprites.
The mouse is humanly controlled and moves in direction of the mouse pointer whereas the 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.
Features
So, our overall game looks like this;
Mouse: is controlled by humans through mouse pointer.
Cat: keeps on chasing the mouse and if chased life is decreased.
Cheese: mouse tries to eat cheese and this increases the score.
Life: Mouse has three lives.
Score: Mouse has to get 10 pieces of cheese to make the score equal to 10 for winning the game.
A Game Plane for Cat and Mouse
Let’s quickly jot down our key requirements for the 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 the sprite
- Create variables of life and score.
Selecting a backdrop
Choose a simple and plain backdrop from the library or create your own from built-in paint on scratch. Here I am creating my own plain background. Click on the paintbrush and start creating.

Here, I am using a simple grey color background made by a center-filled rectangle. Check the image for better understanding.
Our backdrop is ready.

Creating Sprites
Let’s create all of our required sprites at once by clicking on the paintbrush then we will proceed to code.

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 the library.

Selecting Mouse
Select a mouse from the sprite library.

Making Cheese
Again click on paint and draw triangle cheese or select any food from the sprite library. I have made my own cheese.
http://13.251.177.223/wp-content/uploads/2020/09/5-2.png
You Win
Make You Win sprite by clicking on paint, select text, and write You Win.

Game Over
Make Game Over sprite by clicking on paint, select text, and write Game Over.

Making Variable
Go to data & blocks. Create variables of life and score by clicking on create variables and name them as life and score.


CODING for Developing Games in Scratch
Let’s start putting lives to our spirits.
Code the Cat
We want our cat to start from a specific point and keep on chasing the mouse throughout the game whenever the green flag is clicked.
Drag whenever the 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 the 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 the mouse. Now, code the mouse to move 5 steps in direction of the 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 points always.
Cheese is named as sprite 2.
This is the coding of first
Cheese Sprite 2

Create a 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 the game starts.

Variable of life
Life should change by negative one whenever the cat touches the mouse.
Create if condition in cat sprite that if the cat touches the mouse life should decrease by 1 and make sure to add a 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
The score should change by a 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 the 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 the 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


