Skip to main content

Pacman Game on Scratch Program

 We will make an example of pacman game making with Scratch. Before starting the Pacman Game example that we will do with Scratch, we download the background for the pacman game from the internet and add it to the backdrop part in Scratch.

pacman backdrop for scratch

When the background I downloaded was dark, I painted the dark colors with white. I made the borders thicker. After adding our background to our work, it came to creating the pacman character.

Pacman Game on Scratch Program

I drew a full circle in yellow for the Pacman character. After that, I drew two lines towards the center using the line tool. I erased the remaining part with an eraser. If you want, you can use the erase background tool to erase between two black lines. Thus, our pacman character took his place with his mouth open. I created a guide dot right in front of the pacman character. This will keep us moving. I created a red dot. It's a little obvious, you can make this red dot smaller if you want, you can give it another color and make it more invisible.

how to make pacman on scratch

After creating the Pacman character, it's time to open and close this character's mouth. Above is the code that works. When the green flag is clicked, it waits for 0.1 seconds continuously to switch to the next disguise. There are 2 disguises in our pacman character. The first is a full circle (as if its mouth is closed), the second is a circle shape that we delete a part of with the line tool (as if its mouth is open).

After doing the mouth opening and closing movement, it was time to move the pacman.

Pacman Game on Scratch Program

When the green flag is clicked, we start the game by equalizing pacman's score to 0 and credits to 3 before pacman takes action. (We add them from the Variables menu). I wanted pacman to go to x=0 and y=18 when the game started. You can start the character from the point you want. I'm using the forever code for pacman to move continuously. I will only use the character to rotate, not to move each time you press the arrow keys. I'm going to use the red dot I added inside pacman to keep it moving. If the red dot touches the white color (by white I mean the ground color) go 2 steps. Red, if the color touches the columns (blue color) and not the white color, it will stay there motionless. Thus, we have prevented the pacman from moving when it touches the edges. Our next controls, if the arrow keys are pressed, we made it turn to the necessary directions. Of course, in order to determine the direction of pacman while moving, we used the code from the control menu, and we made it turn in the direction of whichever direction button was pressed from the Sensing menu.

We moved Pacman. Now it's time to eat the orange dots, destroy them and get points in return.

how to make a pacman game in scratch

When pacman (that is, use two) touched our orange dots, hide our time point and release the orange1 news. Let me release a different news issue whenever pacman(dummy 2) touches each point for point increase. This is when the news was released


Increases the initial score of 0 by 5 points. We have 25 orange dots in total. 25 different news will be released. The game will be over when 125 points are reached. This code is written inside the pacman character.

Pacman Game on Scratch Program

Pacman game

Let's move the pacman monsters. When the green flag is clicked, pacman monsters will appear and go to x=1 and y=18. In order to move continuously, we write the coordinates of where we want to move the monsters into the forever command and apply the glide command in this second. It is entirely up to you where you want to move the monsters, it is enough to print the coordinates of the place. Now, the actions that will take place when the pacman monster touches pacman;

Scratch games

When the monster touches pacman, we will release the news called score to reduce the credits. I hide the monster instead of pacman. After 1 second, the monster is visible again and its movement continues. You guys can make pacman private.

Scratch Examples

We were making a news when the monster touched pacman. When this news comes, we check the remaining life, if it is 0, we say you have no more life and stop the game. If the remaining health is not 0, we subtract one. Then we check again. If the remaining health is 0, stop the game. We write these codes inside the pacman puppet.

 

Note: When all the dots are defeated in the game, it can be passed to the 2nd level and pacman does not enter from one side and exit from the other side, in addition to these, you can increase the number of monsters. By doing these we can improve the game.


To download the source code of the program CLICK HERE

To see the running version of the program CLICK HERE

To download background of Pacman CLICK HERE

To download the beasts of Pacman CLICK HERE


Similar Topics

For All Scratch Examples CLICK HERE

For Mblock With Arduino Examples CLICK HERE

Comments

Post a Comment

Popular posts from this blog

How to Make Countdown a Maze Game on Scratch

  We will make a countdown maze game example with Scratch. For the countdown maze game example we will make with Scratch, we upload the maze picture we downloaded to our computer from the scene section to the scratch program. Then we select the object that we will move in the maze section from the choose a sprite section and add it to our scene. We bring the object to be moved to the red point, which is the starting point. First of all, we create a variable named Duration to calculate the elapsed time in the maze from the "Variables" menu When you click the green flag, set the duration variable to 40. Our goal is to get the ball to the finish line in 40 seconds. If our ball object to move, we give the x and y coordinates to go to the red starting point. Our object will not move only once. First of all, we add the "Forever" code from the "Control" menu so that it moves every time we press the arrow key. Now it's time to check which direction key is pres...

Blinking LED with Mblock and Arduino

  We will blink the led with the mblock program. The list of materials that will be used in our led circuit before moving on to the codes of the application we will make with the Mblock program: 1-Arduino Uno 2-BreadBoard 3-LED 4-220Ω Resistor 5-Jumper Cables We need supplies. We add a 220 ohm resistor to the long leg of the Led that we added to our breadboard. We connect one leg of the resistor with a jumper cable to the digital pin 8 of our ardunio uno material (You can connect your jumper cable to any digital pin you want between 2-13). The circuit diagram is below. Now let's come to our codes in mBlock; In the Mblock program, we add the Arduino program starter code from the Robots menu. After adding the forever from the control menu, we add the code to whichever digital pin we connected our led to the inside of the "Robots menu ... we add the code to make the pin low. We write 8 because I connect it to digital pin 8. We do not light our led with the code of s...