+21622886281
Game Scratch

Pacman game with Scratch

Pac-Man is a classic arcade game that was first released in 1980. In the game, the player controls a character called Pac-Man, who moves around a maze eating pac-dots (also called pellets) while being chased by four ghosts. The objective of the game is to score as many points as possible by eating pac-dots and fruit that appear in the maze.

The ghosts, which are named Blinky, Pinky, Inky, and Clyde, chase Pac-Man around the maze trying to catch him. If a ghost touches Pac-Man, the player loses a life. However, Pac-Man can temporarily turn the tables on the ghosts by eating a power pellet, which allows him to eat the ghosts and earn extra points.

Pac-Man is a classic and enduring game that has been enjoyed by players of all ages for over 40 years. It has spawned numerous sequels, spin-offs, and adaptations, and it remains a popular game today.

Scratch is a programming language and online community where you can create your own interactive stories, games, and animations. It is a great tool for learning programming concepts and building skills that can be applied to other programming languages.

You can use Scratch to create a Pac-Man game by following these steps:

  1. Open the Scratch website and create a new project.
  2. Design the maze for Pac-Man to navigate. You can use the drawing tools in Scratch to create the walls and other features of the maze.
  3. Create the Pac-Man sprite (character) and the ghost sprites. You can use the Scratch library or import your own images to use as sprites.
  4. Use the Scratch programming blocks to create the behaviors and movements of the sprites. For example, you can use the “move” block to make Pac-Man and the ghosts move around the maze, and the “turn” block to change their direction.
  5. Add other features to your game, such as pac-dots for Pac-Man to eat, fruit for extra points, and power pellets to allow Pac-Man to eat the ghosts.
  6. Test your game and make any necessary adjustments.

With Scratch, you have the tools to create your own version of Pac-Man or other games.

Description of Pacman game with Scratch:

Pacman was one of the very first games developed around 1980.

The Pacman game is considered one of the most influential and important, and is generally listed as one of the greatest video games of all time!

In this article, we will guide you step by step to create Pacman with Scratch software.

As you build this game, you will be designing both the sprites and the maze. It can be quite complex to program, but the satisfaction of designing your own Pacman game is worth it.

It is a maze arcade game, where the player controls the Pacman, who must eat all the dots of the closed maze, while avoiding the ghosts.

Step 1: Prepare the background

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.

Step 2 Creation of the Pacman sprite:

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:

Step 3: Creating the point sprite:

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.

Step 4: Creating enemy sprites (ghosts):

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 sprite program

Here is the complete enemy-1 sprite program

Here is the complete enemy-2 sprite program

Here is the complete enemy-3 sprite program




1 commentaire

Colchones Tiendas 13-05-2323

Gracias desde el fondo de mi corazón por compartir tu luz y tu conocimiento de manera tan generosa a través de este blog.


Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top