Posted: 25th Sep 2003 12:59
Hi All
Here's a bit of fun code, that will help you Balance The time in your busy day coding.

+ Code Snippet
rem Balance Time demo
rem by HowDo
rem with thanks to Mento and ChipOne who got the clock ticking and Wastisname for getting the balance level.
sync on : sync rate 20: draw to back
set text font "arial" : set text size 12
set text to bold
set text opaque
rem makes a bitmap to change to
create bitmap 1,640,480
rem puts the time into varable the_time$
the_time$=get time$()
rem put time() into intsecondtimer
intsecondtimer=timer()
rem puts us in bitmap 0
a=0 : b=0 :c=0
set current bitmap 0
updatesecondsimage(get time$(),roll#,height#)
a=480
b=480
roll#=340
speed# = 0.0

do
cls
if keystate(30)=1 then a=a-1
if keystate(44)=1 then a=a+1
if keystate(40)=1 then b=b-1
if keystate(53)=1 then b=b+1
if a<0 then a=0
if a>480 then a=480
if b<0 then b=0
if b>480 then b=480
line 0,a,640,b

rem 680.0 here is screen width in pixels (I think)
frac# = roll#/640.0
height# = frac#*b + (1.0 - frac#)*a


if height#<a or height#>b then speed# = speed# - (a-b)*00000.1
if height#>a or height#<b then speed# = speed# + (b-a)*00000.1

roll# = roll# + speed#

rem make sure circle doesn't leave screen
if speed#<0 and roll#<20 then speed# = 0.0: roll# = 20
if speed#>0 and roll#>620 then speed# = 0.0: roll# = 620
if timer()>(intsecondtimer+1000)
rem if it is jump to function with value get Time$()
updatesecondsimage(get time$(),roll#,height#)
rem return from function and give intsecondtimer new timer() to check.
intsecondtimer=timer()
endif
rem circle roll#,height# - 20,20
sprite 1,roll#-text width(the_time$),height#-10,1
sync

loop




function updatesecondsimage(the_time$,roll#,height#)
rem change to bitmap 1
set current bitmap 1
rem set text color randomly

ink RGB(255,255,255),0
rem put the text on the screen
text 0,0,the_time$+"  "
rem grab the text
get image 1,0,0,text width(the_time$)+150,text height(the_time$),1
rem switch back to main screen
set current bitmap 0
rem put sprite randomly on the screen
sprite 1,roll#-text width(the_time$),height#-10,1
rem as below
endfunction a


if anyone can make it more relistic in Balance code post and update.
cheers.