PDA

View Full Version : Keeping Track of Collision Detection


onyxthedog
11-15-2009, 11:32 AM
Hello again,

Wow, it has been a long time since I have thought of doing any game deving. It is nice to see (read, anyway) all of you again. I got real into football last year played, did basketball, and then baseball. I didn't have any time for deving really, but I got back into it during the summer and broke my nose and couldn't play football. I worked on a Linux shell that I adopted while I fine tuned my C skills.

I recently decided that I want to program a few games for the fun of it. I thought that maybe I would program a simple Pong and/or Pacman clone. I was wondering how to manage collision detection on Pacman, because obviously Pong wouldn't be too difficult to detect collisions with, there are only 4 things to test for. With Pacman there is walls, ghosts, point-ball-thingies (yes this is the technical term:lol: ), and food items.

Would it be best to make a linked list of a structure of things to detect collisions with? Or maybe an array of what is being held in the corresponding location on the map?

Thank you,
Onyx

Mihail121
11-15-2009, 01:31 PM
Or maybe an array of what is being held in the corresponding location on the map?


:cool2:

onyxthedog
11-15-2009, 01:34 PM
Thanks Mihail, nice to see you again.

poita
11-15-2009, 06:12 PM
For Pacman, just use a 2D array for the grid. When you enter a grid cell, you collect (collide) with whatever is there. For ghosts, just brute force it.

onyxthedog
11-15-2009, 06:31 PM
For Pacman, just use a 2D array for the grid. When you enter a grid cell, you collect (collide) with whatever is there. For ghosts, just brute force it.
Why not just test for Pacman when the ghosts enter a grid cell?

geon
11-16-2009, 04:38 AM
Why not just test for Pacman when the ghosts enter a grid cell?

Either one is fine. n ghosts testing against 1 pacman == 1 pacman testing against n ghosts.

poita
11-16-2009, 06:26 PM
Why not just test for Pacman when the ghosts enter a grid cell?

It's up to you, but as geon said, you're not saving yourself anything.