Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tile based collision in XNA

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'?

like image 393
Dominic K Avatar asked Feb 23 '10 04:02

Dominic K


2 Answers

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.

like image 90
Brian Rasmussen Avatar answered Oct 04 '22 02:10

Brian Rasmussen


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.

like image 30
smack0007 Avatar answered Oct 04 '22 02:10

smack0007