Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Health Bars For Fighting Game

Author
Message
Riz
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 9th Apr 2009 03:51
Hey how how are you guys i need some help again with my health bars. Ive been able to create my health bars by using the box command and when the characters attack each other they go down. My problem is, is that the only way the health bars work is if the code backdrop on : color backdrop 60 is used. This command covers the background completely blue except the health bars and the characters. My question is how can i have my health bars work without having to use this command. Heres the code im using i got it from an example program in the code data base I appreciate any help you guys can provide.


[ H = 170
H = 470

DO

backdrop on : color backdrop 60

`This is the health box used to increase/decrease
`H is your variable. Basically, when you add to H, the box grows and when you subtract, it decreases.

box 20,50,H,75
box H2,50,615,75

`It wouldn't be fair to have a million+ health.
`So now we add some control factors
If H >170
H=H-0.01
endif

If H2 >470
H2=H2+0.01
endif


`Now, it's not necessary to have this function, but we can limit the minimum health to 0 in the same way
If H<0
H=H+0.01
endif

If H2<0
H2=H2+0.01
endif



if sprite hit(2,4)
play sound 4
H=H-1
endif

if H = 0
delete sprite 2
center text 320,240, "Player 1 Wins!"
Wait 5000
`GOTO GAMEOVER:
endif

if sprite hit(4,2)
play sound 4
H2=H2+1
endif

if H2 = 0
delete sprite 4
center text 320,240, "Player 2 Wins!"
Wait 5000
GOTO Gameover
endif

`You can also add more advanved features to your health bar. Simple, but effective
`((int(H/1))*1) This line is used to round your health to the nearest 1's place.
set cursor 5,60
print "Health "+str$((int(H/1))*1)

set cursor 470,60
print "Health "+str$((int(H2/1))*1)
sync
loop]
Databug
15
Years of Service
User Offline
Joined: 27th Oct 2008
Location: Elsewhere
Posted: 9th Apr 2009 05:39
It worked for me...
You don't really even need the backdrop on anyway just replace it with a cls. also the health text doesnt even show up so you might want to type it at the top of your program, sprite it and paste over the health bar.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 13th Apr 2009 05:44
Also, post your code in [code ][/code ] tags so it's easier to copy and paste. Also, this can prevent it from getting messed up if you use things like hex values that the forum will pick up on.



online game videos
14
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 27th Apr 2009 15:10
Errrrmm.....

You May get Adventure games of all genres are good really so I reccomend them!
If you want a game where you can make your own family, and watch your kids grow then visit Griefster its an online game website.

http://www.griefster.com/
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 28th Apr 2009 00:35
And how is that related to the issue at hand?



Cian Rice
19
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 29th Apr 2009 22:18
Quote: "And how is that related to the issue at hand?"


That, my friend, is what we call spam.

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size

Login to post a reply

Server time is: 2024-04-26 23:07:06
Your offset time is: 2024-04-26 23:07:06