Programming the game Cat and Mouse with Scratch

We have learned how to program the game Hung Tao and Racing Animals with Scratch . Next, let's learn how to program the game Cat and Mouse.

Table of Contents

How to program the game Cat and Mouse

From the name Cat and Mouse, you can grasp the structure of this game. So let's start programming this game.

Step 1: Choose a wallpaper for the game

To make the game more interesting, the first thing to do is to choose a background. You can choose the scene of the mouse-tailed cat indoors, outdoors, on the beach... by clicking on Choose background in the bottom right corner.

Programming the game Cat and Mouse with Scratch

Step 2: Set up character for game

This is a Cat and Mouse game, so of course we will need 2 characters Cat and Mouse. Go to Add Character in the Character Frame to choose 2 characters Cat and Mouse according to your preferences.

Programming the game Cat and Mouse with Scratch

Don't forget to delete the default character if you don't want to use it by clicking on the trash icon next to the character.

Step 3: Programming the Cat character

We need to set up the cat to move 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 the green flag of the Event section into the programming section.
  • Select Continuous code in Control section.
  • Add Go to the Motion section mouse pointer .
  • Point towards the object (_) in Motion. The (_) part selects the object as the mouse.

Programming the game Cat and Mouse with Scratch

Step 4: Programming the Mouse character

To make the mouse run everywhere and hide from the cat, you will need to program it as follows:

  • Drag the code When clicking the green flag of the Event item into the programming interface.
  • Add Continuous under Controls .
  • In the Motion section , add Glide for (_) seconds to random position. The (_) box should be set to 1 so that the mouse moves at a moderate rate.
  • Finally add Restart if edge touched also under Motion.

Programming the game Cat and Mouse with Scratch

To make the game more vivid, you can add sound for the mouse every time it is caught by the cat by programming as follows:

  • Add If code (_) then make it a child of Continuous code. In (_) add Touching code (_) and select cat character.
  • Insert the Start Sound code (_) under the Sound section . In the (_) section you can set the sound to match the mouse when it is caught by the cat.

Programming the game Cat and Mouse with Scratch

You can also set it up so that every time it is caught, the mouse will disappear and reappear in another location.

  • Drag the Hidden item in the Show into a child of the If (_) then code.
  • Insert code Go to random position under Move down.
  • Add the Wait (_) seconds code under Controls . In the (_) section you can set the number of seconds to wait for the mouse to reappear in the game interface.
  • Finally, insert the Show code in the Display section .

Programming the game Cat and Mouse with Scratch

Step 5: Publish the Cat and Mouse game

After completing all the above steps, you have finished programming the Cat and Mouse game. You can refer to the game programming code that Quantrimang has made below and edit and add to your liking.

Programming the game Cat and Mouse with Scratch Programming Code for Mouse

Programming the game Cat and Mouse with ScratchProgramming Code for Cats

Finally, you just need to publish the game you just programmed. Click View Project Page in the toolbar at the top of the screen to save the game and start the game experience.

Programming the game Cat and Mouse with Scratch

At the interface you were just navigated to, click the green flag button to start testing the game you just programmed.  Programming the game Cat and Mouse with Scratch

Above is the complete detailed guide on how to program the Cat and Mouse game with Scratch that Quantrimang wants to introduce to you. Wish you success in programming and experiencing this game.

Sign up and earn $1000 a day ⋙

Leave a Comment

Top 10+ Zombie PC Games, best zombie games on PC

Top 10+ Zombie PC Games, best zombie games on PC

Zombies have always been an attractive theme in PC games and horror movies. Game publishers have exploited this theme and achieved much success thanks to the zombie horror genre.

Download game Disaster, download Disaster for free

Download game Disaster, download Disaster for free

The game Tai Uong has now been officially released and allows players to download it on their computers via the game distribution platform Steam.

How to play T-rex dinosaur game on Chrome when offline and have Internet

How to play T-rex dinosaur game on Chrome when offline and have Internet

To play dinosaur game - T-rex Run on Chrome when offline and when online, you just need to follow these simple instructions. The lovely T-rex dinosaur will appear on the screen for you to start the game.

6 benefits of playing games on laptop

6 benefits of playing games on laptop

There has long been a debate among gamers about whether to use a laptop, desktop, or console for gaming. While each option offers its own benefits, gaming on a laptop stands out in a unique way.

5 things to know before adding mods to your game

5 things to know before adding mods to your game

If you're looking for a new experience, there are a few things to keep in mind before adding a mod to your game.

How to fix low FPS problem when playing games on Windows

How to fix low FPS problem when playing games on Windows

If you are experiencing low FPS issues while playing games on Windows, follow these steps to fix low FPS issues and get back to a high-quality gaming experience.

The Game Awards 2024: Who wins GOTY?

The Game Awards 2024: Who wins GOTY?

Want to know who won GOTY 2024? The Game Awards 2024 or want a quick recap of all the winners, read from start to finish

11 Fun Mobile Games to Play Without the Internet

11 Fun Mobile Games to Play Without the Internet

There are many games that you can enjoy without Wi-Fi connection or data usage. If you are looking for such offline games then this article is for you.

Why do many people prefer PC gaming over consoles?

Why do many people prefer PC gaming over consoles?

For a short time, many people believed that console gaming was better than PC gaming. However, after they returned to the world of mouse and keyboard, consoles were left behind.

How to use Xbox Game Pass for free

How to use Xbox Game Pass for free

While Xbox Game Pass is a bargain, its $9.99 (or $19.99 for Ultimate) monthly cost puts it out of reach for some gamers. Luckily, there's a free way to get Xbox Game Pass every month.

GTA Vice City command codes, Grand Theft Auto: Vice City cheats

GTA Vice City command codes, Grand Theft Auto: Vice City cheats

GTA Vice City cheat codes details are for PC version of the game only. GTA Vice City cheat codes will be used for health, weapons, vehicles added to the game as usual.

All about Game Mode on Windows

All about Game Mode on Windows

Game Mode, Windows 10/11's performance booster, can do more than just squeeze a few extra frames per second out of your favorite FPS.

Experience AtlasOS, a super-light version of Windows 10 optimized for gaming

Experience AtlasOS, a super-light version of Windows 10 optimized for gaming

AtlasOS is a redesign of Windows 10 for gamers, enabling smooth gameplay, higher FPS, and lower input and latency even on low-end PCs.

Programming the game Cat and Mouse with Scratch

Programming the game Cat and Mouse with Scratch

We have learned how to program the game Catching Apples and Racing Animals with Scratch. Next, let's learn how to program the game Cat Chasing Mouse.

Top 8 Tips for Gaming Beginners

Top 8 Tips for Gaming Beginners

Whether you're a curious newcomer or someone looking to pick up an old controller, starting your gaming journey can be both exciting and intimidating. However, with the right advice, getting into gaming can be a fun and rewarding experience.