Collisions

Published August 22, 2007
Advertisement
Since posting my last entry, where I had a "playable" little platformer, I've had to go quite a bit backward to implement the features I want. (I put playable in quotes, because absolutely nothing happened when you collided with enemies. But you could jump around between platforms.)

I've done two things that I think are interesting.

1) I've played around the the XNA Content Pipeline. I made a simple animation file format (currently it's just XML) that the pipeline can load up automatically like it can handle textures or meshes. It's not useful yet, but it's a neat experiment on how to add something to the pipeline.

2) Collision detection research. The collision detection I was using before was simply checking Rectangle.Intersects, and then moving the character back to prevent the collision. That's not terribly exciting, and certainly doesn't help at all with sloped surfaces.

My plan is to use two methods of collision. Sprite vs. Platform collisions will be handled with the separating axis theorem (thanks for pointing that out Mr. Easily Confused), and bounding box plus nearly pixel-perfect collision for Sprite vs. Sprite collisions.

Now for some "exciting" screenshots. You control one of the red boxes, using the arrow keys to move, and the A and D keys to rotate. The other red box will push you away on collision (SAT collisions) and collision with the big 'C' looking texture (nearly pixel-perfect) will just change the background to yellow.



And here's the source code. It requires all of the XNA Game Studio Express stuff. I'm still trying to get my head fully wrapped around C#, plus it's just an experiment so don't expect the world's best code.

Previous Entry Time to have some fun
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

Advertisement