Percentage

R

Remer1

Guest
Is there any way we can use percentage type in gml of game maker 8. I want to use it for my HP bar as if one percentage is lost the sprite of HP bar will reduce sprite index by 1.
 
S

Simon Docherty

Guest
Are you saying you have a health bar sprite who's size you want to reduce in 1% increments?
 
A

Aura

Guest
Code:
image_index = ((global.hp / global.max_hp) * 100) - 1; //Subtract 1 because image indexes start at 0 and image index 99 is actually 100th image
Anyways, do you really have to use a 100-images sprite? You could easily do a healthbar by using a frame sprite and another sprite to fill the frame with. Draw the frame first, then the fill sprite using draw_sprite_part() and defining the part of the sprite to be drawn.
 
R

Remer1

Guest
for this i thank you for the code. i am making a pokemon game and this hp bar is for battling screen. i got a gif imahe of hp bar so i thought i could use it.
 
R

Remer1

Guest
Code:
image_index = ((global.hp / global.max_hp) * 100) - 1; //Subtract 1 because image indexes start at 0 and image index 99 is actually 100th image
Anyways, do you really have to use a 100-images sprite? You could easily do a healthbar by using a frame sprite and another sprite to fill the frame with. Draw the frame first, then the fill sprite using draw_sprite_part() and defining the part of the sprite to be drawn.
Can I cut that -1 part because there is also a zero part for the healthbar which is the zero percent. For example the sprite has 101 frames that is 100 in the reading first one or zero one for 0 HP. I think that it is 0-100%
 
Top