This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-17 12:11:07

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Pacman: ghost- choose path

I was wondering how in a pacman game, how do you make it so the ghosts come o an end and choose a random path to move down. I'm not actually making this, I was just curious, so you don't really need to write out a 10 page script. I just need a broad description, or a long one if you want.

Offline

 

#2 2012-03-17 16:20:48

MaxFlyboy
Scratcher
Registered: 2011-11-07
Posts: 100+

Re: Pacman: ghost- choose path

when gf clicked
forever
if <touching [wall v]?>
set [direction choosing v] to <pick random [1] to [4]>
if <<direction choosing>=[1]>
point in direction [0]
end
if <<direction choosing>=[2]>
point in direction [90]
end
if <<direction choosing>=[3]>
point in direction [180]
end
if <<direction choosing>=[4]>
point in direction [-90]
end
end
It's not the most efficient way, but it will work. It will go in direction 90, or -90, or 0, or 180. If there's a wall there it will just do it again.


http://cdn.voodoofilm.org/images/upload/thumb/viral-video-2011.jpg click the picture for an AMV

Offline

 

#3 2012-03-17 16:33:36

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Pacman: ghost- choose path

I once toyed around with Pacman and Scratch.  I basically stored all of the intersection's x and y positions and what directions their respective walls were in, and then chose out of those walls.  More mathematical than MaxFlyboy but his way works just as well (probably actually a lighter work-load).

You might be interested to know that the "real" Pacman isn't random.  Each ghost follows very specific rules.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-03-17 17:32:01

12_lassy
Scratcher
Registered: 2011-07-23
Posts: 13

Re: Pacman: ghost- choose path

MoreGamesNow wrote:

I once toyed around with Pacman and Scratch.  I basically stored all of the intersection's x and y positions and what directions their respective walls were in, and then chose out of those walls.  More mathematical than MaxFlyboy but his way works just as well (probably actually a lighter work-load).

You might be interested to know that the "real" Pacman isn't random.  Each ghost follows very specific rules.

Except for Clide. Clide's is perfectly random. I wonder why... He's always been the dullest knife in that drawer, hasn't he?


http://i552.photobucket.com/albums/jj357/12_lassy/scratchsiggy.png

Offline

 

#5 2012-03-17 19:01:41

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Pacman: ghost- choose path

Actually, even Clide follows rules.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer