   Collision detection for a 2d game
  Hallo,Im wondering how to do collision detection for my simple 2D game. I get how to do it with sprite VS sprite, but not sure how to check the sprites against the actual level.I have been thinking about having a "collision image" for the level, just a black and white picture of the level to do the collision test.How is this normally handeled in a 2D game?Thanks,Ole Kristian   
Quote:Original post by h3roI have been thinking about having a "collision image" for the level, just a black and white picture of the level to do the collision test.That's one way to do it, and it will work fine if implemented correctly.Quote:How is this normally handeled in a 2D game?You could:Do as you already described, and keep collision data as an image (if you're not using it, you could even put this information into the alpha channel of your actual background image if you wanted to and are using a format which supports this).Keep a collection of bounding boxes or other collision geometry and test for collisions against those as you would with a sprite.  You'd probably want to figure out a way of dividing these up to avoid lots of unnecesary checking if your levels are very complex.Store an "outline" of your level mathematically and check against those.I'd suggest trying out the method you originally thought of yourself; it will work, and it's always a good learning exercise to try to figure these things out for yourself, so trying your own method could be good practice.   