Most of my work this week focused around getting the stone potion working.
One of the first things I had to do was split some of my existing Entity code out into smaller pieces. All the entities I’d written previously were sprites, but the stone potion spawns geometric shapes. I ended up pulling the sprite-related code out into a SpriteEntity class, derived from Entity, so that I could customize entity rendering behavior without having to duplicate the code for mantling, collision detection, etc.
Once that was done, I was able to spawn stone outcroppings at the point of impact of a stone potion, based on the surrounding geometry. The player could walk across them and destroy them. This quickly revealed that there were some issues with my algorithm for walking on surfaces: previously, all the surfaces in the game were simple geometric shapes – rectangles, triangles, circles. The stone outcroppings are irregular surfaces, which meant that some of the assumptions I made previously no longer hold.
Previously, to determine where on a surface the player should stand, I checked the left and right edges of the player along with his center. In order to account for irregular surfaces, I now have to scan across the entire width of the player in small increments to account for variations in height. It’s a slight performance hit, but it ensures that the player can walk smoothly over irregular surfaces cobbled together from multiple stones.
I also discovered that I’d made a mistake when implementing my damage effect code – the code in the XNA framework for maintaining a smooth framerate introduced timing inconsistencies between frames, such that the points where I sampled a damage effect’s curve didn’t match the points I sampled initially when computing the total damage (as described in the previous post). The result was that sometimes a potion would do more or less damage depending on the timing of its impact and the game’s current framerate. The solution to this was to maintain an internal clock for each damage effect so that I could walk along the curve at the same points in time.
The next thing I noticed was that the player had difficulty grabbing onto stone outcroppings and mantling up onto them. It turned out that there were two problems there:
The first problem was that the algorithm for finding a point to mantle onto assumed square surfaces. As a result, the uneven, rounded shape of the stone outcroppings caused it to sometimes select points below or above the surface of the stone. I rewrote the algorithm to work in two stages: First, sweep upward to find an obstruction, starting at the player’s feet, and then sweep upward further to find the end of the obstruction and a new place for the player’s feet to occupy.



#1 by Derek on May 15, 2009 - 9:32 am
Quote
Hello! Really nice site you’ve got. I’ve had a lot of fun reading through some of your entries. Just wanted to say keep it up, man. This is definitely one of hte nicer platform games I’ve see so far made with XNA. You’ve got a great sense of weight when moving the player around in the videos. That’s is something you DO NOT see in almost every platformer that I’ve seen. The collision handling is also really nice. Again, a real notch above the typical XNA guy. I’ve subscribed to the feed(which, BTW, I think there might be a problem with the link. I had to toss out the “feed:” part at the start of the feed url before I could subscribe. I’m using Opera.) Looking forward to what you come up with next.
#2 by Kael on May 15, 2009 - 10:09 am
Quote
@Derek
Thanks for the comment. The feed link seems to work for me in Firefox, but I’ll see if I can figure out why it’s not working in Opera.