## Re: [Pgu-devel] collision detection

 Re: [Pgu-devel] collision detection From: Clint Herron - 2010-04-13 04:14:53 Attachments: Message as HTML ```On Mon, Apr 12, 2010 at 9:53 PM, karanveer singh wrote: > I'm making a pacman clone in which I need to do collision detection > between my player, ghosts and tiles. Whenever the ghost reaches an > intersection, if he gets blocked from above (or below) I tell him to > go right or left according to where the player is. And if he gets > blocked from right or left, I tell him to go up or down depending on > where my player is. > The problem is, when there is an intersection at a right angle, the > ghost first gets blocked from, say above, and goes right and then gets > blocked again and goes back above and gets blocked again... thus > getting stuck in a cycle. Something like this: > > > player > > tile tile tile tile tile tile > ghost tile > tile > tile > > Anyway to deal with this? > > Thanks, > Karanveer Singh > > The complex way would be to implement true pathfinding (such as A*). The simple way (that I would probably go for) is to just implement a random factor, that 1/4 or 1/6 of the time or something, the ghost will move in a completely random direction upon intersecting a wall -- that would eventually break the ghost out of its infinite loop, while still generally tending towards chasing the player. --clint ```

 [Pgu-devel] collision detection From: karanveer singh - 2010-04-13 01:53:11 ```I'm making a pacman clone in which I need to do collision detection between my player, ghosts and tiles. Whenever the ghost reaches an intersection, if he gets blocked from above (or below) I tell him to go right or left according to where the player is. And if he gets blocked from right or left, I tell him to go up or down depending on where my player is. The problem is, when there is an intersection at a right angle, the ghost first gets blocked from, say above, and goes right and then gets blocked again and goes back above and gets blocked again... thus getting stuck in a cycle. Something like this: player tile tile tile tile tile tile ghost tile tile tile Anyway to deal with this? Thanks, Karanveer Singh ```
 Re: [Pgu-devel] collision detection From: Clint Herron - 2010-04-13 04:14:53 Attachments: Message as HTML ```On Mon, Apr 12, 2010 at 9:53 PM, karanveer singh wrote: > I'm making a pacman clone in which I need to do collision detection > between my player, ghosts and tiles. Whenever the ghost reaches an > intersection, if he gets blocked from above (or below) I tell him to > go right or left according to where the player is. And if he gets > blocked from right or left, I tell him to go up or down depending on > where my player is. > The problem is, when there is an intersection at a right angle, the > ghost first gets blocked from, say above, and goes right and then gets > blocked again and goes back above and gets blocked again... thus > getting stuck in a cycle. Something like this: > > > player > > tile tile tile tile tile tile > ghost tile > tile > tile > > Anyway to deal with this? > > Thanks, > Karanveer Singh > > The complex way would be to implement true pathfinding (such as A*). The simple way (that I would probably go for) is to just implement a random factor, that 1/4 or 1/6 of the time or something, the ghost will move in a completely random direction upon intersecting a wall -- that would eventually break the ghost out of its infinite loop, while still generally tending towards chasing the player. --clint ```
 Re: [Pgu-devel] collision detection From: Russell Sears - 2010-04-13 06:25:40 ```Here is a nice writeup of the algorithms used in the original arcade game (especially chapters 3 and 4): http://home.comcast.net/~jpittman2/pacman/pacmandossier.html -Rusty karanveer singh wrote: > I'm making a pacman clone in which I need to do collision detection > between my player, ghosts and tiles. Whenever the ghost reaches an > intersection, if he gets blocked from above (or below) I tell him to > go right or left according to where the player is. And if he gets > blocked from right or left, I tell him to go up or down depending on > where my player is. > The problem is, when there is an intersection at a right angle, the > ghost first gets blocked from, say above, and goes right and then gets > blocked again and goes back above and gets blocked again... thus > getting stuck in a cycle. Something like this: > > > player > > tile tile tile tile tile tile > ghost tile > tile > tile > > Anyway to deal with this? > > Thanks, > Karanveer Singh > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Pgu-devel mailing list > Pgu-devel@... > https://lists.sourceforge.net/lists/listinfo/pgu-devel ```