Sign in to follow this  
  • entries
    7
  • comments
    6
  • views
    6519

Collisions

Sign in to follow this  
Jesse Chounard

269 views

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.

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now