Discuss Scratch

docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

How do you make a Pac-Man game but playing as a ghost?
Specter22
Scratcher
100+ posts

Pac-Man (play as a ghost)

The Question is, can you make a Pac-Man game? If so then You shouldn't have too much trouble switching sides.
docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

Specter22 wrote:

The Question is, can you make a Pac-Man game? If so then You shouldn't have too much trouble switching sides.
I am working on one, but it's unshared. I might next week.
docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

If I play as a ghost, how does the Pac Man AI work?
speckosaurus
Scratcher
100+ posts

Pac-Man (play as a ghost)

docnathan wrote:

If I play as a ghost, how does the Pac Man AI work?
You could make Pac Man constantly move until he reaches an intersection (like he hits a wall or he can choose between two paths), then use a random number to decide which direction he goes in and continue moving.
For more complex AI you could make him always move towards the nearest objects he can eat, and also think about how you can make him run away from the ghost if he gets too close to it.
docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

What if he eats a power pellet?
speckosaurus
Scratcher
100+ posts

Pac-Man (play as a ghost)

docnathan wrote:

What if he eats a power pellet?
Think about it: what happens to Pacman when he eats a power pellet in the game? He becomes invincible and the ghosts run away from him.
In this case, he will start chasing your ghost and it is up to the player to run away.

Your collision detection might look something like this:
when green flag clicked
forever

if <touching [pacman v] ?> then

if <(powerup) = [1]> then

broadcast [game over v]
else
change [score v] by (10)
broadcast [kill pacman v]
end

end

Use the “powerup” variable to keep track of whether Pacman is invincible or not. When he eats a powerup, set it to 1. When the powerup runs out, set it back to 0
docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

speckosaurus wrote:

docnathan wrote:

What if he eats a power pellet?
Think about it: what happens to Pacman when he eats a power pellet in the game? He becomes invincible and the ghosts run away from him.
In this case, he will start chasing your ghost and it is up to the player to run away.

Your collision detection might look something like this:
when green flag clicked
forever

if <touching [pacman v] ?> then

if <(powerup) = [1]> then

broadcast [game over v]
else
change [score v] by (10)
broadcast [kill pacman v]
end

end

Use the “powerup” variable to keep track of whether Pacman is invincible or not. When he eats a powerup, set it to 1. When the powerup runs out, set it back to 0
It cannot be game over when the ghost is eaten, it should turn to eyeballs and move back to the start.
docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

Pac man should also have three lives. The player should win when all the lives are gone.
speckosaurus
Scratcher
100+ posts

Pac-Man (play as a ghost)

I was just giving an example of what you might do. I didn't actually say what those messages would do, I just gave them possible names that might make sense. You should easily be able to adapt my code for what you need.

Last edited by speckosaurus (Sept. 4, 2015 00:53:38)

docnathan
Scratcher
100+ posts

Pac-Man (play as a ghost)

What are all the blocks for the Pacman AI?

CPU Unit wrote:

What are the blocks for the AI?

Last edited by docnathan (Sept. 4, 2015 15:28:29)

speckosaurus
Scratcher
100+ posts

Pac-Man (play as a ghost)

docnathan wrote:

What are all the blocks for the Pacman AI?

CPU Unit wrote:

What are the blocks for the AI?
Have you tried it for yourself yet? This forum isn't to get people to do all your work for you. It is to get help, tips, suggestions, etc. of how you would code something. Try it first and if something won't work, then you can ask for help on the specific issue.
fastrunner25
New Scratcher
1 post

Pac-Man (play as a ghost)

what is web site for the game?????????!!!!!!!!!!!!
BKFighter
Scratcher
1000+ posts

Pac-Man (play as a ghost)

fastrunner25 wrote:

what is web site for the game?????????!!!!!!!!!!!!
Please don't necropost.

Powered by DjangoBB