|
-
Dec 24th, 2002, 10:26 AM
#1
Thread Starter
Addicted Member
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.
-
Dec 24th, 2002, 08:45 PM
#2
Addicted Member
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.
-
Dec 25th, 2002, 07:07 AM
#3
Fanatic Member
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.
-
Dec 25th, 2002, 09:50 AM
#4
Thread Starter
Addicted Member
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.
-
Dec 25th, 2002, 11:17 AM
#5
Frenzied Member
Try something like this:
VB Code:
Dim Health As Single
Private Sub Form_Load()
Health = 5
End Sub
Sub PlayerHurt()
Health = Health - 1
If Health = 4 Then
'Code for removing square 5
ElseIf Heath = 3 Then
'Code for removing square 4
ElseIf Heath = 2 Then
'Code for removing square 3
ElseIf Heath = 1 Then
'Code for removing square 2
ElseIf Heath = 0 Then
'Code for removing square 1
'Die!
End If
End Sub
-
Dec 25th, 2002, 12:45 PM
#6
Thread Starter
Addicted Member
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.
-
Dec 27th, 2002, 06:10 PM
#7
New Member
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
-
Dec 31st, 2002, 12:31 PM
#8
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|