I have drawn tiles in my XNA game and loaded my character. My character, however, doesn't move- the map does, which gives it the illusion of movement. Now I am wondering how to actually test against them for collision. I mean, where does the collision code go and how do I make all tiles represent 'one big thing'?
5
votes
Could you clarify the situation a bit? ie. How are you using the tile map in your game? Does the character occupy a single tile or multiple tiles (a la Tetris)? Do game obstacles occupy multiple tiles? I'm at a bit of a loss, since I would think collision detection would be a simple matter of comparing the character's position against obstacles in the tile map, rather than pixel-based collision detection...
– Syndog
4 Answers
5
votes
There's a tutorial on pixel based collision detection on XNA Creator's club. You'll need to figure out what objects you want to do collision detection on. I guess you want the character to move across the tiled background, so you don't want to check for collision between your character and the background. Instead you should make any obstacle s sprites and do collision detection on those.
1
votes
You might have a look at Nick Gravelyn's Tile Engine Tutorials, it goes through the whole process of creating a tile engine. There's a link here to see all the tutorials on YouTube.
0
votes
You could have a look at the Platformer Starter Kit, it shows how to organize tiles in a map and check for collisions.