Pac-Man is one of the most iconic and influential video games in history. First released in 1980 by the Japanese company Namco, it quickly became a worldwide arcade sensation and a symbol of retro gaming.
Objective of the Game
The main goal in Pac-Man is to navigate through a maze, eat all the dots (pellets), and avoid being caught by the ghosts. The player controls Pac-Man, a yellow, circular character with a big mouth, who must collect points while surviving each level.
Gameplay Mechanics
The player moves Pac-Man using arrow keys or a joystick.
The maze contains small pellets (10 points) and larger power pellets (50 points).
Eating a power pellet temporarily turns the ghosts blue, making them vulnerable — Pac-Man can then eat them for bonus points.
The game gets faster and harder as levels progress.
Main Characters
Pac-Man: The hero of the game, always hungry for pellets.
The Ghosts:
Blinky (red) – chases Pac-Man directly.
Pinky (pink) – tries to ambush him.
Inky (blue) – unpredictable.
Clyde (orange) – switches between chasing and wandering.
Each ghost has its own AI pattern, making the game strategic, not just fast.
Scoring
Eating a dot: 10 points
Eating a power pellet: 50 points
Eating a ghost (after power pellet): 200 → 400 → 800 → 1600 points (doubles with each ghost)
Bonus fruit sometimes appears for extra points.
a) Create a new Scratch project
b) Remove the default cat sprite
c) Add or draw these sprites:
Pac-Man
Ghosts (1–4 with different colors)
Walls/Maze (as a backdrop or as sprites)
Dots (as clones of a single sprite)
1) Go to import a background to add the space image.
2) Choose the Labyrinth image for the game background:
3) We obtain the background containing the labyrinth image.
The Pacman sprite is played using the directional keys on the keyboard.
This sprite has 6 costumes:
costume 1: gives the effect that the Pacman’s mouth is open.
costume 2: gives the effect that the Pacman’s mouth is closed to show that the Pacman is eating dots.
costume 3, costume 4, costume 5 and costume 6 give the effect that Pacman loses his life when hit by the enemy (ghost) sprite.
.
We are going to create a Pacman sprite containing 6 costumes.
1) Go to import a sprite to add the pacman-1 image.
2) Choose the pacman-1 image:
2) Go to the Pacman sprite’s costume to add the second costume:
3) Choose the pacman-2 image:
We repeat the two steps 2 and 3 to insert the four other costumes to obtain a sprite containing 6 costumes.
4) Adding program blocks:
We insert the block when the green flag is clicked from the Events category:
Place Pacman in the initial position using this block from the Motion category.
Show the Pacman sprite at the start of the game
Then we switch the Pacman sprite to the pacman-1 costume
The rest of the program is inserted into the repeat forever block:
You must control the movement of the Pacman in the four directions (up, down, right and left) using the arrow keys on the keyboard.
If Pacman touches the blue lines of the Labyrinth, he moves back 2 steps.
If Pacman touches the point sprite, we switch the Pacman sprite to the pacman-2 suit to give the effect that Pacman eats the point sprite.
Then go back to the pacman-1 suit.
If Pacman touches one of the 4 enemy sprites (Ghost), we switch pacman to the 4 costumes pacman-3, pacman-4, pacman-5 and pacman-6 to give the effect that Pacman is destroyed and we hide it permanently of the game scene.
Finally here is the complete Pacman sprite program:
Point type sprites are eaten by PACMAN when he touches them. For each sprite eaten, one point is earned.
1) Go to the new sprites section and select the paint icon.
2) Draw the point sprite using the drawing editor.
3) Inserting program blocks:
On board, we must create the variable score.
The set score to 0 block is executed when the green flag is clicked.
Then we insert the Show block from the Appearance category to display the brick at the start of the game.
The endless loop code block allows its contents to be repeated indefinitely.
We insert the If Then block into the repeat forever loop.
*
To check if the point sprite is touched by Pacman, we use this block:
If the point sprite is touched by Pacman, the score variable is incremented by 1
and the point sprite disappears from the scene using this block:
Here is the complete point sprite program:
Finally, we duplicate the sprite point by clicking on the right mouse button to obtain other copies and place them in the game scene.
In this game, four enemy (ghost) sprites (pink, green, orange, blue) are used, each with different moves. If they touch PACMAN, the latter loses a life.
1) Go to import a sprite to add the pacman-1 image.
2) Choose the enemy image with blue color:
We repeat steps 1) and 2) to create the other enemy sprites:
3) Inserting program blocks:
It is important that enemy ghosts move on their own. We will see how to program the game so that the ghosts can slide through the maze.
We start by inserting the block when the green flag is clicked from the Events category:
Place the enemy sprite in the initial position using this block from the Motion category.
We insert the code block of the loop repeat indefinitely which allows to repeat its content in an unlimited way.
The rest of the program will be inserted into the repeat forever loop.
This block will place the enemy sprite in front of all other sprites.
For the sprite to follow a well-determined path in the maze, we will use the block drag in () seconds to x() y() which drags the sprite to the position defined by the abscissa x and the ordinate y on the scene.
Here is the complete enemy-1 sprite program
Here is the complete enemy-2 sprite program
Here is the complete enemy-3 sprite program
Here is the complete enemy-4 sprite program
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info