Advertisement

Collision detection

Started by January 15, 2000 08:23 PM
0 comments, last by Brad 24 years, 11 months ago
I''m using a tile map in my game I am wondering how to produce "solid" tiles. Basically how do I go about designating certain tiles as solid? (I have no idea to even begin this and it''s rather important)Once I have them designated how do I get the game to recognize them (Do I just loop through the map and hold the coordinantes of the solid blocks in an array?) than how do I test to see if my sprites have hit these blocks? (Do I loop through the array of solid blocks and test to see if each one hits my sprites?) Basically what I''d like is a whole general rundown on how to perform sprite-tile collision detection because I am REALLY confused and BADLY in need of help.
Well one way is basicly you have a flag for each tile indecating weather its walkable or not. Then when you go to move your sprite for example you store his current x and y in another variable, move him and test to see if the tile hes trying to move to is unwalkable.If it is restore his old x and y cordinates.This can get tricky though depending on the size of the sprite(Mainly if hes bigger than the tile(he''ll be touching multiple tiles)Otherwise im not real sure myself I know I used the above in several games and it worked ok but often required tweaking for each sprite.

Hope this helps some.

This topic is closed to new replies.

Advertisement