Jump to content

  • Log In with Google      Sign In   
  • Create Account


Damage Mechanic


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 ghigared   Members   -  Reputation: 133

Like
0Likes
Like

Posted 18 August 2013 - 12:17 PM

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. 



Sponsor:

#2 shadowisadog   Crossbones+   -  Reputation: 2159

Like
2Likes
Like

Posted 18 August 2013 - 12:39 PM

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.


Edited by shadowisadog, 18 August 2013 - 12:44 PM.


#3 SonicD007   Members   -  Reputation: 453

Like
2Likes
Like

Posted 18 August 2013 - 12:41 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS