Sloped platform collision July 28, 2010Posted by Jesse in : Game Development , 6 comments
Recently on the XNA Creator’s Club forums there have been several posts on how to handle collisions with a sloped platform in a 2d platformer. I wrote up a short description of the system I’m using:
How to determine if a player is about to land on a line segment:
What we need:
- Foot position of the player. (Bottom center of the player’s collision rectangle works well.)
- Line segment we’re checking for collisions with, specified by its end points A and B.
- Player’s velocity.
Let’s get to it:
- Is the player moving down? If not, we can stop here.
- Is the player’s expected position (foot position + velocity) within the horizontal region of the segment? If not, we can stop.
- Calculate the interpolated Y position on the line segment of the player’s X position both before and after the move.
- If the Y position before moving is above the segment, and the Y position after moving is below, then the player is landing.
And today I’ve put together a quick sample project to go with that. You’re welcome to do whatever you want with the code. (License – Ms-PL.) I hope it’s helpful. Feel free to hit me with any questions.
Boss fight! July 6, 2010Posted by Jesse in : Game Development , add a comment
We’ve added the first boss fight into the game. Bossfrog is a giant version of the existing frogs you’ve seen before. After taunting our hero, he proceeds to try to stomp him into the ground. Twice during the fight, he’ll roar with anger and summon a bunch of his minion frogs to join in the battle.
Here’s a video: