Jump to content


Keeping Track of Collision Detection


6 replies to this topic

#1 onyxthedog

    Senior Member

  • Members
  • PipPipPipPip
  • 467 posts

Posted 15 November 2009 - 07:32 PM

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
/* Perfect_day.c */
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........

#2 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1052 posts

Posted 15 November 2009 - 09:31 PM

onyxthedog said:

Or maybe an array of what is being held in the corresponding location on the map?

:cool2:

#3 onyxthedog

    Senior Member

  • Members
  • PipPipPipPip
  • 467 posts

Posted 15 November 2009 - 09:34 PM

Thanks Mihail, nice to see you again.
/* Perfect_day.c */
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........

#4 poita

    Senior Member

  • Members
  • PipPipPipPip
  • 322 posts

Posted 16 November 2009 - 02:12 AM

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.

#5 onyxthedog

    Senior Member

  • Members
  • PipPipPipPip
  • 467 posts

Posted 16 November 2009 - 02:31 AM

poita said:

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?
/* Perfect_day.c */
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........

#6 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 891 posts

Posted 16 November 2009 - 12:38 PM

onyxthedog said:

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.

#7 poita

    Senior Member

  • Members
  • PipPipPipPip
  • 322 posts

Posted 17 November 2009 - 02:26 AM

onyxthedog said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users