Small function that let you position the bars and size to use if you sound or speed or helath bars.
Rem Project: movingbars
Rem Created: Friday, November 20, 2009
Rem ***** Main Source File *****
sync on
sync rate 60
RANDOMIZE timer()
INK RGB(0,255,0)
global volume as float
global max_vol as float
global text_max$
delay=1000
t=timer()
DO
volume=RND(68)
if timer()>t+delay
speed_bar(volume,68,240,440,325.0)
t=timer()
endif
sync
LOOP
function speed_bar(volume as float,max_value,bar_x,bar_y,barsize_x as float)
ink rgb(255,255,255),0
pp#=(volume/max_value*100)*(barsize_x-10)/100
`p#=p#/barsize_x
rem text blacker
box bar_x,bar_y-10,bar_x+barsize_x+20,bar_y,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
rem grey back box
box bar_x,bar_y+3,bar_x+barsize_x,bar_y+12,rgb(64,64,255),rgb(64,64,64),rgb(64,64,255),rgb(64,64,64)
box bar_x,bar_y+12,bar_x+barsize_x,bar_y+22,rgb(64,64,64),rgb(64,64,255),rgb(64,64,64),rgb(64,64,255)
rem gery ends
box bar_x,bar_y+3,bar_x+5,bar_y+22,rgb(64,64,64),rgb(64,64,64),rgb(64,64,64),rgb(64,64,64)
box bar_x+barsize_x-5,bar_y+3,bar_x+barsize_x,bar_y+22,rgb(64,64,64),rgb(64,64,64),rgb(64,64,64),rgb(64,64,64)
rem moving green bar
BOX bar_x+5,bar_y+5,bar_x+5+pp#,bar_y+10,rgb(0,255,0),rgb(64,64,64),rgb(0,255,0),rgb(64,64,64)
BOX bar_x+5,bar_y+10,bar_x+5+pp#,bar_y+20,rgb(64,64,64),rgb(0,255,0),rgb(64,64,64),rgb(0,255,0)
rem text for moving bar top and bottom
ink rgb(255,255,255),0
text bar_x+5+pp#,bar_y-12,str$(volume,0)
rem black lines
for ii= 0 to barsize_x-5 step 5
ink 0,0
line bar_x+5+ii,bar_y+5, bar_x+5+ii,bar_y+20
next ii
rem max keeper
if pp#>max_vol
max_vol=pp#
text_max$=str$(volume)
else
rem draw red line
if max_vol>0
ink rgb(255,0,0),0
text bar_x+5+max_vol,bar_y-12,text_max$
BOX bar_x+5+max_vol-1,bar_y+5,bar_x+5+max_vol+1,bar_y+20, RGB(255,0,0),RGB(255,0,0),RGB(255,0,0),RGB(255,0,0)
endif
endif
endfunction
as above but with a 3d object on screen.
Rem Project: movingbars
Rem Created: Friday, November 20, 2009
Rem ***** Main Source File *****
sync on
sync rate 60
color backdrop 0
autocam off
position camera 0,0,-10
make object cube 1,1
RANDOMIZE timer()
INK RGB(0,255,0)
global volume as float
global max_vol as float
global text_max$
delay=1000
t=timer()
DO
rotate object 1, wrapvalue(object angle x(1))+1,0,0
if timer()>t+delay
volume=RND(68)
speed_bar(volume,68,240,440,325.0)
t=timer()
else
speed_bar(volume,68,240,440,325.0)
endif
sync
LOOP
function speed_bar(volume as float,max_value,bar_x,bar_y,barsize_x as float)
ink rgb(255,255,255),0
pp#=(volume/max_value*100)*(barsize_x-10)/100
`p#=p#/barsize_x
rem text blacker need if not using cls and have not put an object on screen.
`box bar_x,bar_y-10,bar_x+barsize_x+20,bar_y,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
rem grey back box
box bar_x,bar_y+3,bar_x+barsize_x,bar_y+12,rgb(64,64,255),rgb(64,64,64),rgb(64,64,255),rgb(64,64,64)
box bar_x,bar_y+12,bar_x+barsize_x,bar_y+22,rgb(64,64,64),rgb(64,64,255),rgb(64,64,64),rgb(64,64,255)
rem gery ends
box bar_x,bar_y+3,bar_x+5,bar_y+22,rgb(64,64,64),rgb(64,64,64),rgb(64,64,64),rgb(64,64,64)
box bar_x+barsize_x-5,bar_y+3,bar_x+barsize_x,bar_y+22,rgb(64,64,64),rgb(64,64,64),rgb(64,64,64),rgb(64,64,64)
rem moving green bar
BOX bar_x+5,bar_y+5,bar_x+5+pp#,bar_y+10,rgb(0,255,0),rgb(64,64,64),rgb(0,255,0),rgb(64,64,64)
BOX bar_x+5,bar_y+10,bar_x+5+pp#,bar_y+20,rgb(64,64,64),rgb(0,255,0),rgb(64,64,64),rgb(0,255,0)
rem text for moving bar top and bottom
ink rgb(255,255,255),0
text bar_x+5+pp#,bar_y-12,str$(volume,0)
rem black lines
for ii= 0 to barsize_x-5 step 5
ink 0,0
line bar_x+5+ii,bar_y+5, bar_x+5+ii,bar_y+20
next ii
rem max keeper
if pp#>max_vol
max_vol=pp#
text_max$=str$(volume)
else
rem draw red line
if max_vol>0
ink rgb(255,0,0),0
text bar_x+5+max_vol,bar_y-12,text_max$
BOX bar_x+5+max_vol-1,bar_y+5,bar_x+5+max_vol+1,bar_y+20, RGB(255,0,0),RGB(255,0,0),RGB(255,0,0),RGB(255,0,0)
endif
endif
endfunction
Dark Physics makes any hot drink go cold.