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 Bubble Shooter Game on Scratch Program

 We will make a bubble shooter game example with Scratch. I am adding 3 balloons and a target picture for the bubble shooter game we will make with Scratch. (You can increase the number of balloons). Now I come to the codes to be written inside balloon1. Let the number of balloons popped when the green flag is clicked is 0. Thus, the remaining numbers from the previous game are reset. Let the balloons be hidden at first. Then, it will appear in a random place between the coordinates we have determined at a random time between 1-5 seconds, wait for 2 seconds, then hide. X: The coordinates between -218/144 are the coordinates of the far left and the right of the screen, Y:134/-235 are the coordinates of the top and bottom of the screen. It will appear randomly in these ranges If our balloon is aimed and hit by the target; Balloon shot news is released. When this news reaches our balloon, the balloon will be hidden. Copy and paste the same code above.   Then we say duplicate...

Temperature Measurement Fire Alarm with NTC Sensor with Mblock

 NTC is a temperature sensitive sensor. In this application, we will make a temperature measurement with the NTC Sensor and make a fire alarm application using the Buzzer.     A list of materials:   1-Arduino Uno 2-BreadBoard 3-1 Buzzers 4-1 NTC Sensor 5-Jumper Cables 6-1 LEDs   We need your supplies. We connect the long leg of the Buzzer, which we added to our breadboard, with the jumper cable to the digital pin 11 in our ardunio uno material. We connect the short leg of the buzzer to the GND (negative) terminal of the Ardunio Uno with a jumper cable. NTC Sensor has 2 legs. Their legs are of equal length. We connect a resistor to one of the legs. We connect the end of the resistor to 5 Volts. We connect it to one of the analog pins with a cable from the leg to which we connect the resistor. I connected it as A0. We connect the other leg of the NTC to the GND (negative) terminal. We connect a resistor to the long leg of the LED. From this end, ...