Discuss Scratch

MihirSK
New Scratcher
3 posts

How to make ghosts chase Pacman

Currently, the ghosts are going in random directions. Can someone just guide as to how I can make them reach Pacman. I tried to make them glide, but they just cross over the walls and glide towards Pacman.
Thanks
https://scratch.mit.edu/projects/113790537/
alexphan
Scratcher
1000+ posts

How to make ghosts chase Pacman

It looks like you made two topics containing similar things…?
QuickSilver_18
Scratcher
97 posts

How to make ghosts chase Pacman

You could try using this block

forever

go to [Pacman]
end

Hope this helps
bcstahlman13
Scratcher
100+ posts

How to make ghosts chase Pacman

Hey MihirSK. I'm not a really experienced Scratcher, but I though I'd try to help with this issue. It seems to me that, at any time, a ghost may change either its x or y position, or occasionally both. (It can move either left and right, or up and down, depending on the location of the nearest wall) You'll have to create some logic to test which directions it can move. If it can change its x position without running into a wall, change its x position to more like pacman's. Similarly, if it can change its y position with hitting a wall, change its y position to be more like pacman's. You probably won't be able to use just a go to, or move towards pacman solution, because they will cause the ghost to move diagonally (and go through a wall). Let me know if this helps. Good luck and happy Scratching!
bcstahlman13
Scratcher
100+ posts

How to make ghosts chase Pacman

Basically, you just have to change either the x or y position of the sprite, but not both at once. It's up to you how you want to handle it when you can choose either.
ERS0606
Scratcher
1 post

How to make ghosts chase Pacman

I can't figure out how to do it !!!!!!!!!!!!!!!!!!!!!!!!!!!
gtoal
Scratcher
1000+ posts

How to make ghosts chase Pacman

https://web.archive.org/web/20150212054502/http://pacman.shaunew.com/play/index.htm

click on the ‘learn’ button. it shows how the ghosts work…
gamemakerboy123
New Scratcher
1 post

How to make ghosts chase Pacman

QuickSilver_18 wrote:

You could try using this block

forever

go to [Pacman]
end

Hope this helps
this didn't work…….
904509
Scratcher
1 post

How to make ghosts chase Pacman

alexphan wrote:

It looks like you made two topics containing similar things…?
Thank you for speaking about net nuetrality, but I don't think this is the time and place for that.
Anyway, I don't know how to do that snazzy thing when you have blocks in your comments, but here is how you can make pacman move.
Forever go to pacman take 3 steps. And then, add another one that says forever if not yellow touching blue, take 3 steps. Hope this helps!
CodeNinja23
Scratcher
7 posts

How to make ghosts chase Pacman

904509 wrote:

alexphan wrote:

It looks like you made two topics containing similar things…?
Thank you for speaking about net nuetrality, but I don't think this is the time and place for that.
Anyway, I don't know how to do that snazzy thing when you have blocks in your comments, but here is how you can make pacman move.
Forever go to pacman take 3 steps. And then, add another one that says forever if not yellow touching blue, take 3 steps. Hope this helps!
If your talking about putting on the ghost script, does not work… the character is on top of Pac Man 24/7.
Despicable_Dad
Scratcher
500+ posts

How to make ghosts chase Pacman

Firstly, only let the ghost make a decision when it arrives at a junction in the maze. Then have the ghost take a few steps down each of the possible routes in turn. Each time, record the distance to pacman from that position, before returning to the junction. Finally, decide which route to go down based on which gave the shortest distance.

Powered by DjangoBB