Help with health-player!

Get help using Construct 2

Post » Wed Aug 28, 2013 1:29 pm

How to create an algorithm that, when picked up bonus health was adding to the player's health, but that would be the total number of health does not exceed the maximum possible amount of health?

For example: A player has 80% health. 100% of maximum health sniper. The player picked up a health bonus +30% health. How to make what amount of HP was 100%, not 120% (80 +30)?
B
7
S
3
G
5
Posts: 7
Reputation: 3,764

Post » Wed Aug 28, 2013 1:54 pm

Never work with percentage in your code, here is a better way:

The player has 2 instance variables: health and max health

Health = 300
MaxHealth = 400

+ On Pickup bonus Health
-> MaxHealth * 1,3;

//Now the event to show the right percentage of life
+ Every Tick
-> Set Text(Life) to round(Health / MaxHealth * 100)
B
15
S
6
G
6
Posts: 512
Reputation: 5,555


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION, tarek2 and 18 guests