Basic Health Bar

31.  Add 3 game properties to the health bar
  • Logic Editor menu >> View >> Properties
  • Properties tab >> Add Game Property button
Note:
  • We are adding 3 game properties that will be used as variables by the python script.
     
  • One for the sensor name.  Another for the actuator name.  And the last for the health.
     
  • This way we can use one (and only one) python script for ALL of the Health Bars in the game.
32. First Game Property
  • Logic Editor >> Properties tab >> Property Name: sen
     
  • Logic Editor >> Properties tab >> Property Type: String
     
  • Logic Editor >> Properites tab >> Property Value: Message
Note:
  • Property Name must be named sen (for Sensor).  
     
  • The code in HealthBar.py looks for a string Game Property named sen.
     
  • Property Name is the name of your message sensor.  I left mine with the default name of Message
33. Second Game Property
  • Logic Editor >> Properties tab >> Property Name: act
     
  • Logic Editor >> Properties tab >> Property Type: String
     
  • Logic Editor >> Properites tab >> Property Value: Property
Note:
  • Property Name must be named act (for actuator).  
     
  • The code in HealthBar.py looks for a string Game Property named act.
     
  • Property Name is the name of your action actuator.  I left mine with the default name of Property
34. Third Game Property
  • Logic Editor >> Properties tab >> Property Name: Health
     
  • Logic Editor >> Properties tab >> Property Type: Integer
     
  • Logic Editor >> Properites tab >> Property Value: 100
Note:
  • Property Name must be named Health.
     
  • The code in HealthBar.py looks for a integer Game Property named Health.
35.  Action Actuator Type:  Property
  • Action Actuator >> Action Type >> Property