hey
i am making a pacman game i'm trying to make a sprite (ghost) move randomly around the pacman maze not follow pacman but just go anywhere and then when pacman is in a certain rage of the ghost, the ghost chases after him untill he is out of that range and goes back to randomly moving again.
could anyone help on this?
thanks joelly
Offline
Maybe you could use
if not touching color of wall [
<change direction by [90] clockwise>
<change x by (pick random 1 to 20)>
<change y by (pick random 1 to 20)>
]
Offline
Make a colored 'feeler' sensor sprite to read intersections then turn randomly based on how many choices there are. Use the distance and direction to the player to weigh (increase chance of being picked) paths in that direction slightly more heavily. This will let you 1) have ghosts who perform exactly like you want and 2) let you adjust individual ghost's tendencies to chase the player. In the original game some ghosts (red I think) were tougher to evade than others (Blue was easiest) In fact, sometimes you could turn towards Blue and it would reverse away from you like it was scared even if you weren't powered-up.
After reading another recent post on Pacman, I really want to do this myself!! Someone mentioned how hard it would be to code the AI but I think this method of picking through 'weighted' intersection choices pretty much does it. Except for a Power Up routine where they run away and if you make eaten ghosts' eyes or whatever fly back to the middle. Good luck >=P
Offline
Locomule wrote:
Make a colored 'feeler' sensor sprite to read intersections then turn randomly based on how many choices there are. Use the distance and direction to the player to weigh (increase chance of being picked) paths in that direction slightly more heavily. This will let you 1) have ghosts who perform exactly like you want and 2) let you adjust individual ghost's tendencies to chase the player. In the original game some ghosts (red I think) were tougher to evade than others (Blue was easiest) In fact, sometimes you could turn towards Blue and it would reverse away from you like it was scared even if you weren't powered-up.
After reading another recent post on Pacman, I really want to do this myself!! Someone mentioned how hard it would be to code the AI but I think this method of picking through 'weighted' intersection choices pretty much does it. Except for a Power Up routine where they run away and if you make eaten ghosts' eyes or whatever fly back to the middle. Good luck >=P
I always thought the ghosts moved along predetermined paths. ...But I could be wrong. It's been known to happen.
Offline
Couldn't be predetermined because they chase the player when close enough. Instead, the ghosts use 3 sets of movements, scatter, chase, and frightened. They alternate between each set at predetermined intervals which change into chase mode more rapidly at higher game levels. You can tell when they change modes because they reverse direction. So my earlier guess was wrong lol. They use target tiles that differ in relation to the player's position with the red ghost being dead on. That is also why other ghosts seem to ambush you, they are really targeting ahead or around you.
This page is a MUST for anyone wanting to understand the original game and/or make a credible Scratch version....
http://home.comcast.net/~jpittman2/pacman/pacmandossier.html
You learn things tons of stuff, like, although you don't see them on the screen the entire level and all sprite movements are actually tile based. So if you've already tried making a Scratch Pacman run through a hand-sketched maze and wondered "Gee, how do you get him to fly around and turn corners all smooth like in the original?" now you know But hey, the original took almost a year and a half to make, longer than any other of its time. Think I can invest a few days into mine sometime lol. edit- ok, I'm drawing up a scaled game board now, lol.
Last edited by Locomule (2010-06-24 09:54:51)
Offline
Locomule wrote:
Couldn't be predetermined because they chase the player when close enough. Instead, the ghosts use 3 sets of movements, scatter, chase, and frightened. They alternate between each set at predetermined intervals which change into chase mode more rapidly at higher game levels. You can tell when they change modes because they reverse direction. So my earlier guess was wrong lol. They use target tiles that differ in relation to the player's position with the red ghost being dead on. That is also why other ghosts seem to ambush you, they are really targeting ahead or around you.
This page is a MUST for anyone wanting to understand the original game and/or make a credible Scratch version....
http://home.comcast.net/~jpittman2/pacman/pacmandossier.html
You learn things tons of stuff, like, although you don't see them on the screen the entire level and all sprite movements are actually tile based. So if you've already tried making a Scratch Pacman run through a hand-sketched maze and wondered "Gee, how do you get him to fly around and turn corners all smooth like in the original?" now you knowBut hey, the original took almost a year and a half to make, longer than any other of its time. Think I can invest a few days into mine sometime lol. edit- ok, I'm drawing up a scaled game board now, lol.
That makes sense. But what about in "scatter" mode?
Offline
Each ghost sets a new target tile in each of the 4 corners of the map. Each map tile is binary, either blocks or allows passage through. In scatter mode, the ghosts set their target tiles to a tile inside a wall piece in that corner. Since they cannot reach that tile, they just go to that corner and begin running around that wall. Of course, if the player gets too close, a ghost will go into chase mode.
Kind of funny, I was so young when I played Pacman at the arcade, I had no idea about 'uber' gaming lol. So I never noticed the different modes or that you know when they change cause that is the only time the ghosts change direction. Very ironic that mastery was considered learning complicated patterns yet the true master of the game used no patterns. He instead reacted to the ghosts behavior in different modes. The dawning of 'uber gaming' came for me watching some old dude beat every single kid and then the machine on Karate Champ. I finally couldn't take it and when I asked how he did it, he answered simply "defense." I was like, "Ahhhhhhh...!!!"
ps.. I spent last night and today working on mine... have the board drawn, 1/2 of the sprites drawn, and have a routine that generates a huge list to store the binary state of all 1008 map tiles. I kind of panicked cause I thought I would have to do a separate sprite for all the dots (well over 200) but instead decided to put the map onto Scratch's background with all the dots drawn on it. When a player 'eats' a dot, I will use the pen to draw over it, much easier on Scratch's cpu load!
Last edited by Locomule (2010-06-24 20:03:49)
Offline