1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

How do i make 2 health bars help please

Discussion in 'Legacy GameMaker Community Tech Support' started by badboy17, Jun 24, 2019.

  1. badboy17

    badboy17 Member

    Joined:
    Jun 24, 2019
    Posts:
    1
    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
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,327
    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?
     
  3. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    603
    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.
     
    Amon likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice