J
JTrocks55
Guest
So here is the problem I am having. I watched this video: GameMaker - Custom Healthbars
In the video, he explains how to make a healthbar. His healthbar went off of a health value that was maxed at 100, so he showed that you need to draw the healthbar as your health value divided by 100, making it so that the xscale of the sprite equals anywhere from 0 to 1, because it is 0 to 100 divided by 100.
My problem is that in my game, your health starts at 50 (50 divided by 100 is obviously going to be .5, so the health bar shows half health), then you can also upgrade your max health between waves. So what I am looking for is a way to normalize any health value to be 0 to 1. Here is the code that handles the drawing of the healthbar:
As you can see, global.hp/100 won't work in my case.
So, any ideas on how I could get this fixed?
Thanks in advance!
In the video, he explains how to make a healthbar. His healthbar went off of a health value that was maxed at 100, so he showed that you need to draw the healthbar as your health value divided by 100, making it so that the xscale of the sprite equals anywhere from 0 to 1, because it is 0 to 100 divided by 100.
My problem is that in my game, your health starts at 50 (50 divided by 100 is obviously going to be .5, so the health bar shows half health), then you can also upgrade your max health between waves. So what I am looking for is a way to normalize any health value to be 0 to 1. Here is the code that handles the drawing of the healthbar:
Code:
draw_sprite(spr_healthbarbg,0,obj_player.x - 50,obj_player.y - 68);
draw_sprite_ext(spr_healthbarinner,0,obj_player.x - 50,obj_player.y - 68, global.hp/100,1,0,c_white,1);
So, any ideas on how I could get this fixed?
Thanks in advance!