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.
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
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%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.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