I looked about for any examples of code to make a player health bar in the forums and code base and couldn't find any so I made my own.
Being a Noob an all ive realized that there must be a better way of doing this.
REM Project: Healthbar
REM Created: 8/29/2005 08:23:49
REM
REM ***** Main Source File *****
REM ***** By John Keenleyside **
perform checklist for graphics cards
for c=1 to checklist quantity()
name$=checklist string$(c)
next c
set graphics card name$
SET DISPLAY MODE 640,480,32
sync on : sync rate 60 : Autocam off : hide mouse
make camera 1
set current camera 1
set camera range 1,2,8000
backdrop on 1
color backdrop rgb(170,170,255)
set ambient light 25
global NegativeHealth#
global healthbar=1
Draw_Healthbar()
do
text 0,40, "Use the Up & Down keys to Increase & Decrease Health"
paste image healthbar,613,297
Decrease_health()
Increase_Health()
sync
loop
function Draw_Healthbar
BOX 615,300,625,475,rgb(267,123,001),rgb(267,123,001),rgb(123,234,162),rgb(123,234,162)
BOX 625,300,635,475,rgb(123,234,162),rgb(123,234,162),rgb(267,123,001),rgb(267,123,001)
line 613,297,637,297
line 613,297,613,477
line 637,297,637,477
line 613,477,637,477
GET IMAGE healthbar, 613,297,638,478
NegativeHealth#=299
endfunction
function Increase_Health
if upkey()
if NegativeHealth# <299 then NegativeHealth# =299
dec NegativeHealth#
BOX 615,NegativeHealth#,625,475,rgb(267,123,000),rgb(267,123,000),rgb(123,234,162),rgb(123,234,162)
BOX 625,NegativeHealth#,635,475,rgb(123,234,162),rgb(123,234,162),rgb(267,123,000),rgb(267,123,000)
GET IMAGE healthbar, 613,297,638 ,478
endif
endfunction
function Decrease_health
if downkey()
inc NegativeHealth#
BOX 615,299,635,NegativeHealth#,Rgb(0,0,0),Rgb(0,0,0),Rgb(0,0,0),Rgb(0,0,0)
GET IMAGE healthbar, 613,297,638 ,478
endif
endfunction
If any one has some suggetions as to improving it please tell me my minds a blank
I read somewhere that the paste image command was very slow and should be avoided if possible is this true?
Feel free to use any part of this code you want for your own purposes though. Doesn't load any media