So far I have coded a simple Pong clone, and a Tetris clone. Collision detection was very simple in these. Pong: If ball has negative velocity, check collision on left paddle, if ball has positive velocity, check for collision on right paddle. With tetris, I set the board up as an array of 0s (empty), 1s (occupied), and 2s (board boundary), checked board space in the direction in which the piece was about to move, and did stuff based on the result. This may not have been the best way but I wanted to try something different.
Now I am moving on to Sprite-based bounding-box collision detection. I haven't actually started the project yet; however, I am planning for a Pac-Man clone or Pac-Man-esque game if I decide to change it up.
I plan on displaying the board as a series of sprites assigned to different numerical values and load it from an arbitrary file, say "maze1.map", which contains a 2D array of the previously stated numbers based on the shape of the maze piece (vertical, horizontal, corners, and end pieces). I'd like to eventually extend this to a map editor, but may save this for a future project.
:arrow:
!! START HERE IF YOU DON'T CARE ABOUT THE OTHER BULLSHIT !! :: Anyways, I'm wondering how to process collision detection with so many "collidable" sprites on the board at one time (on a game such as pacman, using collidable sprites for maze pieces and precise bounding-box collision). Do I check EVERY sprite on the board for collision every time the frame updates? Or do I divide the board into quadrants, change which quadrant I'm testing based on the area of the character (and ghosts), and only check that quadrant/subquadrants?
I don't need code help or anything with this, just theory on how to handle collision detection.
Thanks