Saturday, May 15, 2010

Baddies are jumpy

As I started testing for bugs, I realized that Baddies would jump to spaces they weren't supposed to be able to jump to. This usually happened after they dropped a bomb, so I figured I miswrote some code somewhere. Turns out that it's just that the explosion and bomb is being drawn OVER the baddy, so it appears the baddy has jumped, but really, he has just been moving under the cover of their green explosion. Sometime earlier, I fixed this problem with my player, but I don't recall how I did it....

1 comment:

  1. There are two things at work here, I think.
    1) That the baddy is disappearing under the explosion, instead of on top of it, and
    2) That the baddy isn't dying in the explosion.

    The first issue is a matter of drawing order - it sounds like your baddy is being drawn before the explosion. The earlier things are in the list of ObjectsToDraw, the lower the level they will be when the drawing happens. So it sounds like you need to have the explosion drawn first, and then the baddy second. Two ways to do this are:
    a) Instead of appending the explosion bits to the objectsToDraw list, insert them at the start of the list: objectsToDraw.insert(0,explosionthing), or
    b) If you always want the baddies on top, don't add them to the objectsToDraw list, but instead have the main program's updateScreen() function blit all the objectsToDraw and then blit all of the listOfBaddies afterwards.

    2) If the second problem is what you are after, it sounds like you need to reexamine (or create) collision detection code to see whether the baddy is touching an explosion. (Make sure to call this function from the animateStep() function, too!) If so, remove the baddy from all the lists it is on.

    Does this answer your question?

    ReplyDelete