Pacman Tutorial 2

From Scalable Game Design wiki
Jump to: navigation, search

How to Read This Tutorial

This Tutorial uses "collapsible boxes":

Overview

Pacman Screen.png

Pac-man-arcade2.JPG

Create a Project and the first agents: Pac-Man & Background

Create a Worksheet


IMPORTANT: Saving the Worksheet

Exclamation.jpeg

While the Worksheet Window is selected, go to File->Save; You only want to save your worksheet at the beginning state (starting point) of the level-- this is what the level will "reset" to when the game is over (ie: place pacman at the position you want pacman to start at before you save)-- So put all the agents at their starting positions before you save. You can test if saving worked, by hitting the "Reset" button in the worksheet window: if the screen doesn't clear (meaning no agents disappeared), you have successfully saved the worksheet window. If the screen did clear, place the agents in the positions they originally were and try to save again following the directions above. If the screen still clears, Ask for Help.

Program a Cursor-Controlled Pac-Man

WorksheetRunButton.png
Play Test: Controlling Pacman

GOOD JOB! You have now created and saved the first version of the level. Now let's test our program by running it and trying to play the game to see if it works the way we think it should. In the worksheet window, hit the 'Run' button located at the bottom left. What happens?

  • Can you control Pacman movements with the arrow keys?
  • Does Pacman Look in the direction you move?
  • Finally, Does Pacman only move on the Path?

If the answer to these are yes! Great Job.

If not, Re-look at your Pacman Behaviors, Compare with your neighbor or ask for help.

Create Pellets & Ghost agents

Place new agents on worksheet to create complete Level


WorksheetRunButton.png
Play Test: Testing Level with Pellets

Try to run your game

  • Does Pacman Move anymore?

The answer should be no. The reason Pacman does not move anymore is because instead of the Path/Background, the Pacman sees the Pellets. So we have to make it so that if Pacman sees a Pellet in a given direction, Pacman "Eats" the Pellet (makes it disappear) in a addition to moving that direction.

Pac-Man moves on and eats Pellets

WorksheetRunButton.png
Play Test: Pacman moving and eating Pellets

Try to run your game Again

  • Does Pacman Move and eat the Pellets?

If the answer is yes good job! If the answer is no recheck your Pacman behavior, compare with a neighbor, or ask for help.

Randomly moving Ghosts

WorksheetRunButton.png
Play Test: ghosts moving

Try to run your game

  • Does the Ghost move randomly around the screen?

If yes good job!

  • Does the ghost kill pacman?

Not yet, We'll program that next!

Ghosts tells Pac-Man to deflate

Pac-Man deflates



WorksheetRunButton.png
Play Test: Finished game?

Play the Game For awhile. Can you move Pacman around? Does it change direction n the way it moves? How about the ghosts-- is it hard or easy to avoid the ghosts? if everything is working well, Great Job! Right now the Ghosts are moving randomly, it makes for a fun game but couldn't the ghosts be smarter in their pursuit of Pacman? We will now add a scent to Pacman that the ghosts can follow.

Making the Ghosts "Smarter": using AI to track the Pac-Man

We're giving Pacman a scent value and the ghosts follow Pacman's scent in order to figure out where Pacman is rather than moving randomly across the maze. But before Jumping Into Behaviors, Let's Read the Collaborative Diffusion pattern to get a better idea of what we're programming (you don't have to understand all of it-- make sure to look at the videos). Keep in mind that the idea is simple-- pacman's scent is spread across the stage and the ghosts try to get to the place where the scent is strongest.


Setting Pac-Man's scent

Background & Pellets diffuse Pac-Man's scent

Ghosts track Pac-Man

WorksheetRunButton.png
Play Test: ghosts chase pacman!'

Delete Pacman from the worksheet, and then re-add Pacman. This makes sure that Pacman's scent value is set. Now, Play your game--

  • Does everything work correctly?
  • Do ghosts chase and kill pacman now?

If not go back and see if you can find some mistake. The diffusion code can be tricky. Ask your neighbor or for help if you're stuck.

If so Great Job! Try to add other things such as:

  • power pellets
  • a way to win
  • another level
  • extra lives
  • cherries and other fruit. . .

Use your imagination!