We are going to make a simple game where the user controls and moves a mouse around the screen using the arrow keys. The mouse will increase it’s score everytime it eats a cheese. The mouse dies when it gets caught by the cat, and the game is over.

Unsure where the blocks should be placed? Look at the header, such as 🐭 Position, that means those blocks is for the Mouse Sprite

Get started

Visit Scratch and Create a new project

Start by creating the following sprites and variables for our game:

Sprites

🐭 Mouse Sprite

😼 Cat Sprite

πŸ§€ Cheese Sprite

Variables

🚩 Score Variable

🚩 Highscore Cloud β›… Variable

🐭 Mouse

🐭 Position

Lets make sure that the 🐭 Mouse always starts on the left side of the screen.

when flag clicked
go to x: (-180) y: (0)

🐭 Controls

We are going to move our 🐭 Mouse with the arrow keys.
First we are starting out with forever loop when the green flag is pressed.

when flag clicked
go to x: (-180) y: (0)
forever

Everything inside our forever block is going to run over and over until the game is stopped.

Lets make it possible to move our 🐭 Mouse forward when we press the up arrow key.

when flag clicked
go to x: (-180) y: (0)
forever
if <key (up arrow v) pressed?> then
move (10) steps
end

And make so when the down arrow key is pressed, the 🐭 Mouse will move backwards.

when flag clicked
go to x: (-180) y: (0)
forever
if <key (up arrow v) pressed?> then
move (10) steps
end
if <key (down arrow v) pressed?> then
move (-5) steps
end

Now lets add so when we press either left arrow or right arrow we change the direction of the 🐭 Mouse by rotating 15 degrees clockwise or counterclockwise.

when flag clicked
go to x: (-180) y: (0)
forever
if <key (up arrow v) pressed?> then
move (10) steps
end
if <key (down arrow v) pressed?> then
move (-5) steps
end
if <key (left arrow v) pressed?> then
turn ccw (15) degrees
end
if <key (right arrow v) pressed?> then
turn cw (15) degrees
end

The Mouse can now move around on the screen

πŸ§€ Cheese

πŸ§€ Position

We want the πŸ§€ Cheese to always start in the center of the screen.

when flag clicked
go to x: (0) y: (0)

πŸ§€ Collision

Everytime the 🐭 Mouse collides with the πŸ§€ Cheese it should move to a random position.

when flag clicked
go to (random position v)
forever
if <touching (mouse v)> then
change[score v]by(1
go to (random position v)
end

😼 Cat

😼 Position

The 😼 Cat should always start on the right side of the screen

when flag clicked
go to x: (180) y: (0)

😼 Movement

when flag clicked
go to x: (180) y: (0)
forever
point in direction (mouse)
move (3) steps

😼 Collision, Highscore and Game over

When the cat collides with the mouse we first want to update the highscore, and right after we are going to end the game.

when flag clicked
forever
if <touching (mouse v)> then
if <(score) > (highscore)> then
set [highscore v] to (score)
end
stop [all v]
end

Updated: