Discuss Scratch

JonasMush
Scratcher
22 posts

Pacman ghosts with random directions

Hello Scratchers!
I hope i don't interupt, but i need a little help with something…
I have a made a Pac-Man game but i need ghosts in my maze.
Just like in the game they have random direction, like they choose to go left, right, up or down.
I really don't know how to do this… I have searched tutorials, seek for answers, but no succes.
I have a script, but my ghosts glitch into the wall when it hits it.
Can you guys help me please?
Thank you
wayyyy
Scratcher
500+ posts

Pacman ghosts with random directions

When a ghost goes to a position that it has to make a choice, it should pick a direction based on possible moves at that point.
JonasMush
Scratcher
22 posts

Pacman ghosts with random directions

Oh so i have to make the ghost make a decision when it touches like a point of a corner or crossway?
kritav
Scratcher
100+ posts

Pacman ghosts with random directions

JonasMush wrote:

Oh so i have to make the ghost make a decision when it touches like a point of a corner or crossway?
Yes, depending on the possible directions it can travel in. Because without this the ghost would travel into a wall! So by checking in which direction it can travel, the ghost will make a decision at random.
axisjack
Scratcher
100+ posts

Pacman ghosts with random directions

you can do the above or something like this
forever
move (x) steps
if <touching [wall] ?> then
point in direction (random - current_direction)
end
end

Last edited by axisjack (May 28, 2019 16:54:37)

JonasMush
Scratcher
22 posts

Pacman ghosts with random directions

It's really complicated right now…
I'm gonna try and share it. Maybe you guys can say what i'm doing wrong and learn me something new! Is that ok?
mamallamam
Scratcher
1 post

Pacman ghosts with random directions

I had the same problem so I made barely visibe sprites that followed the intersections and made a message every time the ghost touched it that told it its options but I could not figure out how to make the ghosts pick between is 2, 3, or 4 options? Hope it helps!

Powered by DjangoBB