Results 1 to 8 of 8

Thread: Health meter for game, help!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Unhappy Health meter for game, help!

    Hi everyone, I haven't been to this forum for a long time now. I see a lot of new members, hello everyone!

    As usual I have a question . I have 5 squares in my game at the top right corner of the screen that represent the health of the character. What I want to do is make one square dissapear EACH time the character gets hurt. If I say if hurt = true then square1 dissapear. Thats good but if I continue and say if square1 dissapear = true then square2 dissapear = true...and so on, then they all dissapear at once. I want only ONE to dissapear EACH time character gets hurt.

    Hope that makes sense, thanks.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Just keep a variable with the damage level of the character. When the character is hurt, adjust the variable. Use the variable to determine how many squares to draw. I'm assuming you've got a loop that runs constantly to draw the screen.

  3. #3
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    use a variable for health, everytime character gets hurt, set the correct amount of squares
    Don't pay attention to this signature, it's contradictory.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    Yes but how can I find out which time it is the character gets hurt? I have collision detection code between the enemy and the character, when enemy closes in and touches the character collision = true and hurt = true, this is the first time the character gets hurt, and one square dissapears, but now how can I do the other 4 times? I guess I'll try checking how many squares are visible = false

    Thanks.

  5. #5
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    Try something like this:

    VB Code:
    1. Dim Health As Single
    2.  
    3. Private Sub Form_Load()
    4.     Health = 5
    5. End Sub
    6.  
    7. Sub PlayerHurt()
    8.     Health = Health - 1
    9.     If Health = 4 Then
    10.         'Code for removing square 5
    11.     ElseIf Heath = 3 Then
    12.         'Code for removing square 4
    13.     ElseIf Heath = 2 Then
    14.         'Code for removing square 3
    15.     ElseIf Heath = 1 Then
    16.         'Code for removing square 2
    17.     ElseIf Heath = 0 Then
    18.         'Code for removing square 1
    19.         'Die!
    20.     End If
    21. End Sub
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Cool

    Hey thanks Cyborg, that works great! I just added code so the character gets kicked back each time he gets hurt so that the squares don't disappear all at once.

  7. #7
    New Member
    Join Date
    Dec 2002
    Posts
    12

    hey

    Hey, could you send me your program with the source code? i am just interested and have no intent of stealing it, i'm just trying to learn thanks

  8. #8
    Junior Member
    Join Date
    Aug 2002
    Location
    Phoenix
    Posts
    30
    I posted this a while ago.


    I did the Mana orb.
    The zip includes:
    The .psd file for the graphic (each layer is for each graphic you need. the container, container mask, essence, essence mask).
    The VbProject file along with one form, one module. Just push play to try it.


    http://amithran.hybd.net/downloads/orbTutorial.zip

    heres a screen shot:



    heres the "theory" behind the demo:

    1.) Determine percentage of life you have out of max life.
    ie: life/maxlife (I believe).

    2.) Apply the percentage towards the number of horizontal pixel columns of the orb shape. (% * height) This lets you know how much to fill up the orb with red potion (via diablo style).

    3.) User blitblt with AND and SRC (i believe again) along with a circuler mask in the shape of the orb. Then draw only the percentage height of the orb using bitblt.
    I'm in college now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width