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.

Newcomers DBPro Corner / can someone tell me how to draw a bar on the screen that decreases , for a health bar or energy bar

Author
Message
fussy123
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location:
Posted: 10th Oct 2002 21:27
i have been playing around with the loading bar function , but i cant get it to go the other way ... can anyone give me some help on this?
cls
for bar =1 to 100
sx#=screen width()/2
sy#=screen height()/2
x#=sx#-150
ink rgb(0,0,0),0
box sx#-152,sy#-17,sx#+152,sy#+17
ink rgb(0,0,200),0
box x#,sy#-15,x#+bar*3,sy#+15
next bar
LastOfTheBedroomCoders
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: United Kingdom
Posted: 10th Oct 2002 23:20
Evening...

Dunno for sure, but I think all you might be wanting, is to replace the second line with "for bar = 100 to 1 step -1". It's the "step -1" that does the trick!

Then again, if it wuz me, I might use a sprite - then I could make the bar look 3D by using a vertical gradient on the sprite's image!

Try something like this >>>


rem //// PSEUDO_CODE - IT WON'T COMPILE!

health = 100

load image "16x16_pixel-block", 1
sprite 1, position_x,position_y, 1


rem // GAMELOOP
do

rem // OTHER GAME STUFF GOES HERE...


if player_hit_by_monster()
health = health - 5
if health < 0
goto player_death_sequence
endif
endif

if picked_up_medipack()
health = health +50
if health > 100
health = 100
endif
endif

rem // ON-SCREEN DISPLAY CODE HERE...
rem // SET SIZE OF HEALTH BAR
stretch sprite 1, (10*health),100


rem // MORE DISPLAY STUFF...

loop

QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 14th Oct 2002 05:56
an even better type of bar would be one that changed color, or a premade bitmap where instead of decreasing it's size, you drew blakc boxes over it to hide it. Easy and looks good!

Login to post a reply

Server time is: 2024-03-29 12:58:56
Your offset time is: 2024-03-29 12:58:56