GM Tips - Health and Lives
Note that health and lives are global variables. This means there is only ONE built in health and ONE built in lives. Usually you use these for your good guy. For bad guys, you need to create custom variables.
For good guy health, follow the instructions below. For Bad Guy Health, open the example off the T:drive called Views Example V2.
Because these are global variables, use your background objects to set up and track health and lives. I recommend you do NOT use your good guy itself.
Create event of ObjLevel#
Set lives to 3
Set health to 100 (health should always be tracked out of 100)
No More Health Event (found under Other)
Set lives to -1 RELATIVE
Set health back to 100
No More Lives Event (found under Other)
Display a message
End Game, or another alternative
Draw Event
Draw Health bar with the following coordinates
x1: 400 y1: 400
x2: 500 y2: 425 This creates a bar 100 pixels wide and 25 high.
Or to have the bar follow a character
x1: ObjGoodGuy.x y1: ObjGoodGuy.y
x2: ObjGoodGuy.x + 100 y2: ObjGoodGuy.y + 25
The Most Common Mistake:
The most common mistake when using Health and Lives is to have the event that triggers a drop in health occur multiple times. For example, a bullet collides with the object but the bullet keeps travelling through the object, colliding over and over. Do not forget to either destroy the colliding object (often a bullet) or jump one of the object to a new position.