Hi,
I wrote the following code to move a cube basically back and forth right over another cube. After I wrote it I said to myself there has to be a more efficient and hopefully shorter way to write something so simple. Also, because of the timer functions I used, I am having a lot of trouble doing anything in the main loop because the program goes through the repeat until loops and can't do anything else simultaneously. Any help would be much appreciated.
+ Code Snippetcamz = -20
`set Screen resolution to 1500 by 110 and set colour mode to 32 bit
`Change these settings to make text and sprites appear bigger or smaller in finer detail
`Change the 32 bit colour depending on the colour modes your computer supports
set display mode 1500,1100,32
`creates a 'camera' and positions it(x,y,z) to view objects
make camera 1
position camera 1,0,0,camz
`declares and sets the value for x#
x# as float
x#=0
`rem makes a cube and positions it
make object cube 1,1
position object 1,0,-2,10
`makes a second cube that will move and positions it with the variable x#
make object cube 2,1
position object 2,x#,-1,10
`main loop
do
`calls function to move the top block back and forth
moveblocks()
loop
function moveblocks()
x# as float
x#=7.0
T=Timer()
Seconds=2
Repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 0,0,Str$(TimeLeft)+" "
x#=x#-0.01
position object 2,x#,-1,10
if returnkey()=1 then suspend for key
Until TimeLeft=0
T=Timer()
Seconds=2
Repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 0,0,Str$(TimeLeft)+" "
x#=x#+0.01
position object 2,x#,-1,10
if returnkey()=1 then suspend for key
Until TimeLeft=0
`closes the function
endfunction
Thanks
Data