Boss health bar depletion

This is a discussion on Boss health bar depletion within the Game Programming forums, part of the General Programming Boards category; Hi, I have created a boss health bar for my game, I can make the numbers reduce when it takes ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    Boss health bar depletion

    Hi, I have created a boss health bar for my game, I can make the numbers reduce when it takes damage, but I do not know how
    to make the bar it's self string. A visual example of what I mean is here:

    boss full hp

    Code:
    BOSS 100%[**********]  // can take 10 hits
    now player hits boss 5 times

    Code:
    BOSS 50%[*****     ]   // depelete visual bar and number
    All I am trying to do is make the visual bar deplete., like in metroid prime!! (cool game!) If any one knows of a way to do this or any tutorials I cant find would be greatful! thankx

  2. #2
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    make a 100% string and use substr() to cout less *.
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Code:
    float GetHealthCoef(float Max,float Cur)
    {
      return Cur/Max;
    }
    
    void DrawHealthBar(int x,int y,int maxlength,float health,float maxhealth)
    {
      float coef=GetHealthCoef(health,maxhealth);
    
      int x2=x+maxlength;
      int barlength=x+coef*(x2-x);
    
      for (int i=x;i<barlength;i++)
      {
         //Draw health graphic at i,y
      }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 12:32 PM
  2. progress bar newbie
    By WaterNut in forum Windows Programming
    Replies: 18
    Last Post: 08-09-2004, 01:42 PM
  3. Child window with active (highlighted) title bar: Possible?
    By JasonD in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2003, 06:43 AM
  4. Progress Bar in Status Bar :: No MFC
    By Okiesmokie in forum Windows Programming
    Replies: 4
    Last Post: 05-03-2002, 10:51 PM
  5. Health Bar demo
    By jdinger in forum Game Programming
    Replies: 7
    Last Post: 04-12-2002, 12:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21