Sunday 5 February 2012

Collision.

I am putting some collision code together.

The most important part for any platform game is to collide with the enviroment.

Since the current goal of the game is supposed to be tilebased, the collision is rectangle based. One pass determines if any of the corners of any desired collision rectangle is inside the area of any othere desired collision rectangle. The first simple check just determines if this is true or not.

After that we have the possibility of a shallow check. This allows us to do logic based on the actuall name of the object we are colliding with, like "Player", "Box" etc.

Last but not least we have a deep collision check. This allows the collisionobjects children to be tested as well, so from here we can do more indepth logic, like checking what side of a player collided with what object. If you only can jump on an enemy it would be a collision between "bottom" and "top" we would like to check, any other form of collision would result in damage to the player.

The system itself is put together now it's just testing.

After the collision integration it's time to implement the jump function so the player might do more interesting things then just falling down.

No comments:

Post a Comment