Tuesday, February 18, 2025
banner
Top Selling Multipurpose WP Theme

The Pac-Man recreation wants no introduction. Gamers management Pac-Man, the eponymous character, all through the maze. He’s undoubtedly one of the vital well-known maze video games.

How do I play Pac-Man video games in Scratch?

Gamers should accumulate cash scattered all through the maze. There are additionally some massive cash that provides you with bonus factors if you happen to accumulate them. Nevertheless, gamers should keep away from ghosts that transfer throughout the maze. If the participant touches the ghost, the sport is over.

The participant can management Pacman utilizing the up, down, left and proper keys.

Steps to code a Pac-Man recreation in Scratch

step 1: Create a background on your recreation

The primary background is a Pacman maze.

The second background is the victory background. This background is activated or displayed when the participant collects all of the cash and wins the sport.

Pacman you won screen

The third background is the dropping background. This background is enabled or displayed when the participant loses the sport by being eaten by one in all his ghosts.

Pacman game over screen

Step 2: Create sprites in-game

The primary sprite is the Pacman character. Click on the Add Sprite possibility and add the Pac-Man sprite beneath.

Costume 1 Costume 2

pacman game
pacman game

The second sprite is a pink ghost.[スプライトを追加]Click on the choice to add the sprite beneath.

pacman game background

The third sprite is a inexperienced ghost.[スプライトを追加]Click on the choice to add the sprite beneath.

pacman game background

The opposite sprite is a dot that must be positioned on the primary background.

pacman game background

Create 88 sprites just like the one above with related pictures

The bonus sprite is a big dot that have to be positioned on the preliminary background.

Create 4 bonus sprites as proven beneath.

pacman game background

Step 3: Add code to set varied attributes on Pacman firstly of the sport

Pacman game scratch code

Click on on the flag to show the Pac-Man sprite. Level within the course of 90. Pac-Man’s unique place needs to be on the middle of the maze, at an x ​​worth of 0 and a y worth of -10.

Step 4: Add code to maneuver Pacman utilizing the left, proper, up and down keys.

Pacman code in Scratch

Add the above code beneath when the flag is clicked. This code checks if any key’s pressed. Urgent any key will change your costume each 0.1 seconds, and an animation will seem every time you press a key.

pacman scratch code

Every time you press the left arrow, Pacman’s course adjustments to -90.

Pacman code in Scratch

Every time you press the appropriate arrow, Pacman’s course adjustments to 90.

Pacman code in Scratch

Every time you press the up arrow, Pacman’s course adjustments to 0.

pacman scratch program

Every time you press the down arrow, Pac-Man’s course adjustments to -90.

Step 5: Add code for Pacman to the touch the maze wall

pacman scratch game

Add the above code to all everlasting loops related to all 4 main occasions.

This code checks if the black colour touches the maze’s background colour, black, and solely Pacman wants to maneuver two steps every time a key’s pressed.

Step 6: Add code to maneuver the pink ghost randomly inside the Pacman maze.

pacman game code
pacman game code

When the flag is clicked, the message will likely be broadcast. respawn1 Transfer the pink ghost up each time the pink ghost receives a message. When the ghost touches the partitions of the maze, it strikes down. In any other case it is going to proceed to maneuver horizontally. The ghost variable is the velocity at which the ghost strikes horizontally. The worth is 2, which implies the ghost continues to maneuver to the left till it touches the wall. When it touches the wall, it adjustments course and begins transferring to the appropriate, and vice versa.

Step 7: Add code to randomly transfer the inexperienced ghost inside the Pacman maze.

Write code for the Pacman game
Pacman game in Scratch

When the flag is clicked, the message will likely be broadcast. respawn1 Transfer the pink ghost up each time the pink ghost receives a message. When the ghost touches the partitions of the maze, it strikes down. In any other case it is going to proceed to maneuver horizontally. The Ghost2 variable is the velocity at which the ghost strikes horizontally. The worth is 2, which implies the ghost continues to maneuver to the left till it touches the wall. When it touches the wall, it adjustments course and begins transferring to the appropriate, and vice versa.

Step 8: Add code to every dot within the maze

Pacman game coded in Scratch
Pacman code for scratch programming

Clicking on the flag creates a dot at x place 24 and y place -10. Change these values ​​for every dot in order that the sample appears to be like just like the one beneath. When Pac-Man touches these dots, the dots are hidden, indicating that Pac-Man has collected the dots, and 10 factors are earned.

Step 9: Added bonus dot codes to mazes

pacman code

It is the identical code because the small dot. Change the x and y values ​​for every bonus dot. If Pac-Man touches a dot, 100 factors are earned and Pac-Man hides.

Step 10: Add code to win the sport

Pacman game in Scratch
scratch pacman

If the worth of the variable dot is 92, you win. The background will change to a victory background.

Step 11: Add code to lose the sport

Pacman game in Scratch
Pacman game with MIT Scratch programming

Add the code to each ghosts when the flag is clicked. Add whenever you obtain the code to the background of your recreation.

I hope this helps you create your individual Pacman recreation on the Scratch platform. thanks.

Additionally learn: VBA Programming for Children, Coding Flappy Chook Sport in Scratch, Kangaroo Math Class for Children

banner
Top Selling Multipurpose WP Theme

Converter

Top Selling Multipurpose WP Theme

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

banner
Top Selling Multipurpose WP Theme

Leave a Comment

banner
Top Selling Multipurpose WP Theme

Latest

Best selling

22000,00 $
16000,00 $
6500,00 $

Top rated

6500,00 $
22000,00 $
900000,00 $

Products

Knowledge Unleashed
Knowledge Unleashed

Welcome to Ivugangingo!

At Ivugangingo, we're passionate about delivering insightful content that empowers and informs our readers across a spectrum of crucial topics. Whether you're delving into the world of insurance, navigating the complexities of cryptocurrency, or seeking wellness tips in health and fitness, we've got you covered.