• entries
686
1952
• views
387719

# Bug-hunt...um...yay?

85 views

Yesterday I finished up the animation code for the player sprite. It looks really good(by my standards anyway).

I spent most of that time tracking down an annoying bug with the animation code. When the player was next to a ledge, it would use the jumping animation, even though it was clearly on the ground. It was really hard to track down the problem.

The problem essentially was due to the fact that I treated manually jumping and falling off a ledge as the same action. This made it easier to handle situations where the player fell off ledges. However, I found that the only way to fix this animation bug was to have the program know the difference between jumping and falling.

If that was confusing to understand I apoligize, but it is hard to explain what exactly was the problem. I only understand it because I was the one who actually wrote it.

I should have gotten a screenshot of it before I fixed it, because it looked pretty funny.

Also, I started programming enemies into the game. In the past when I've created multiple enemy types, I would have a single enemy class and a variable inside that class that says what type of enemy it is. Than I would use a switch statement to handle the behavior of each enemy. So something like this:

switch(enemy_type){NINJA:    // Do ninja stuff    break;PIRATE:    // Do pirate stuff    break;}

This is fine if I'm writing a game with C. However, I'm writing a game with C++, so I think I should take advantage of polymorphism for this task.

So for instance, instead of the above code, I would now have:
Enemy *bob = new Ninja();Enemy *bill = new Pirate();bob->doStuff();bill->doStuff();delete bob;delete bill;

Ofcourse it won't look like that, but that is the general idea of what I'll be doing.

I haven't actually gotten any enemies working yet, but I have my Enemy base class working. Hopefully I'll have some screenshots when I'm done with that.

I can empathize with the animation issues; I dealt with the same kind of beef when I wrote Magma Duel. :) Similar issues arose for me when I tried to unite the jump/fall states, but I ended up taking the same route and having them work individually.

It's kindof a drag too. I thought I was soooo clever when I thought of making jumping and falling the same action. Ofcourse, when I actually added animation that all fell apart[sad]

## Create an account

Register a new account