• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

How do i make 2 health bars help please

B

badboy17

Guest
Was trying to make a game where the player has a health bar and a shield bar but i cant do it, i have tried a lot of different stuff but it won't work. if u know the code for it please send it to me i need it for my game thank you

the health bar and shield bar should be in top left corner of the screen hp bar on above the shield bar
 

FrostyCat

Redemption Seeker
This silver-platter treatment you expect is not how things work around here. Put in some real effort. At the very least, post the code you used.

Have you read up on global variables and draw_healthbar()? Did you put the drawing calls in the Draw event and put an instance of that object in the room?
 

pixeltroid

Member
First set your players health to 50 in his create event.

Then create an object called "obj_hud" and put this in its draw event.

Code:
//draw healthbar
draw_sprite_ext(spr_health_fill, 1 ,view_xview[0] + 14, view_yview[0] + 15, obj_player.health/100,1,0, c_white, 1);
draw_sprite(spr_health_border, 1 , view_xview[0] + 14, view_yview[0] + 15)
For the first line of code, create a sprite called spr_health_fill that is a flat color. This becomes smaller if you take hits or grows if you collect health.
For the second line of code, create a decorative border sprite called spr_health_border -- but make it bigger than the first sprite because it is the decorative border around the health bar.
 
Top