Monday, May 10, 2010

Killing Baddies

ok, so i've got my enemies working, and there's a bit of a glitch if they collide off the left side of the screen, but thats not too important.

So I thought of making the floor bounce up if my player hit it, and I worked on that, but had some trouble getting it to work, because sometimes my player hits the floor, and other times the block to prevent him from getting stuck in the floor. Anyways, I sort of got it working, but then decided that if i just made a new rect for my player that extends above the rect of the player so that when the player jumps, if he hits his head on either the roof or block, the extended rect will go through the floor and hit the enemy (if there is one). of course, this creates the problem of an enemy falling from above and hit my player from the top, but I think if I add a bit to my code, requiring the enemy to be on the floor to be affected by this new rect, I should avoid this problem.

Your idea to make the enemy jump when he is hit is a good idea, I hadn't thought of that. I do have it so that he jumps when he is hit after he is upside down, but then all my enemies fall through the floor (whether i hit them or not). Theres probably one line somewhere i need to fix. further more, once i hit my enemies from below, they don't stop moving even though i changed its xVel to 0.

The next thing to do is to get my enemies to get hit and die like i want them to, get my player to jump only one time (instead of when i press up even if he's in the air), and get my yoshi so that if he dies and then hits an enemy, he doesn't bounce again.

1 comment:

  1. It sounds like you are in a good place. If your various objects have flags in their classes (e.g., IAmDead, IAmFlipped, IAmHittable), then it should be a fairly straightforward process to revisit your functions that check for these interactions and have them check to see whether the objects are eligible for the interaction. (For example, when you are checking to see whether a turtle has hit the floor, check whether the turtle is already dead first...)
    I suspect you are almost ready for some graphics and sounds!

    ReplyDelete