Damage Mechanic

Started by
1 comment, last by SonicD007 10 years, 8 months ago

Hello, Been working for about 6 months now on my own indie title: Space Adventure. I need help no how to implement a damage mechanic as they did in the old Megaman and Castlevania games. I am meaning when megaman would take damage from the enemy he would jump back, and would be invincible for a few seconds.

So far my engine handles the user being hit by the enemy, and vice versa. Damage is taken by the user/enemy, but he stands still, no real damage mechanic has been worked out.

I would appreciate any help and thank you in advance!!!

The engine and game are being developed using strictly Java and slick2d. I have 5+ years software development and programming experience.

Advertisement

When the player takes damage you could play an animation and/or move the player away from the enemy. You could add a "invincible" boolean flag and set it to true to prevent the player from taking more damage. When the animation finishes then you could set the invincible flag to false. You could also have the player "blink" to indicate that they are immune to damage (you could blink while the invincible flag is true). One way to accomplish the "move away from the enemy" bit is to record the previous x position at some interval and when you take damage you could move to this previous x position. You may want to make sure you only record the x position when the player is standing on a platform though, because otherwise you might jump them back to their death (although this could be part of the game mechanic).

I hope this helps.

I've never programmed this feature myself but I would go about implementing it as a "DAMAGED" state where the character would temporarily not respond to user input. During this state, the character would display the injured graphic and would move back x amount of pixels. Once the time limit of this DAMAGED state has worn off, the state would transition back into "NORMAL" state. There would be an entering function for when a state is transitioned to or from another state so the normal state would have an enter method so to speak in which it would check what the last state was (in this case DAMAGED) then it would act based on what the previous state was. So for this megaman damaged look, when the state goes from DAMAGED to NORMAL, give the player control of his character again and begin the temporary invincible timer.

Take a look at the Finite State Machine pattern. This might be able to explain it better than I can.

http://gameprogrammingpatterns.com/state.html

This topic is closed to new replies.

Advertisement