This is what I have, I can used "t" becasue it returns with an arbitray number. I am lost on what to do and yes I should comment more often but you get that.
Sync On
Sync Rate 30
Hide mouse
Backdrop on
color backdrop 0
autocam off
position camera 0,70,120
Set camera range 1,10000
position camera 0,70,120
point camera 0,0,0
`load image "batmouse.tga",1 `load images
`sprite 1,0,0,1
`load music "music.wma", 1
`loop music 1
global t as float
global oldtime as integer
oldtime = 0
global range as integer
range = 300
global n as dword
n=timer()
global rate as dword
rate=1000
points as float
lr as boolean
lr=0
fog on
fog distance 4000
fog color RGB (120, 180, 200)
global cameraOldX as float
global cameraOldY as float
global cameraOldZ as float
global health as integer `set health
health = 100
global acceleration as float `set acceleration, this value determines how fast the player moves
acceleration =10.0
Rem create level
createlevel()
Rem Main loop
Do
SC_UPDATEOBJECT 1
SC_UPDATEOBJECT 2
hittest()
Movement()
text 0,100,str$(t)
t = timer()
if timer() - t > 1000
print "working"
endif
if acceleration =< 5
acceleration = 5
endif
if lr = 0
if mouseclick()=1
acceleration = acceleration -1
acceleration = acceleration+press()
lr=1
endif
else
if mouseclick()=2
acceleration = acceleration -1
acceleration = acceleration+press()
lr = 0
endif
endif
text 0,0,str$(acceleration)
text 0,16,str$(timer()-n)
text 0,50,str$(oldtime)
remstart
print "cubeX ", object position x (2)
print "cubeY ", object position y (2)
print "cubeZ ", object position z (2)
print "cameraX ", camera position x (0)
print "cameraY ", camera position y (0)
print "cameraZ ", camera position z (0)
remend
position object 2, camera position x(0), camera position y(0), camera position z(0)
box 10, 10, health*2, 20, rgb (255,0,0),rgb(255,0,0),rgb (255,0,0),rgb(255,0,0)
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
Rem Control input for camera
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
Rem Refresh Screen
Sync
Loop
function createLevel()
load object "cave2.x",1, 0
SC_setupComplexObject 1 , 1 , 2
SC_AllowObjectScaling 1
scale object 1, 500, 500, 500
position object 1,0,70,120
rotate object 1, 0, 180, 0
make object sphere 2, 2, 2, 2
SC_SETUPOBJECT 2, 2, 0
endfunction
function Movement()
Move camera 0 + acceleration
endfunction
function hittest()
oldx#=camera position x()
oldy#=camera position y()
oldz#=camera position z()
move camera acceleration*2
x#=camera position x()
y#=camera position y()
z#=camera position z()
move camera - acceleration*2
collision = SC_sphereCast ( 1, oldx#, oldy#, oldz#, x#, y#, z#, 50, 0 )
if collision >0
health = health - 1
fog color RGB (255, 0, 0)
`fog color RGB (120, 180, 200)
`acceleration = acceleration - 1
normx = SC_getCollisionNormalX()
normy = SC_getCollisionNormalY()
normz = SC_getCollisionNormalZ()
position camera 0,sc_getCollisionSlideX(),sc_getCollisionSlideY(),sc_getCollisionSlideZ()
point camera 0, oldx# + normx, oldy# + normy, oldz# + normz
endif
endfunction
function press()
diff=timer()-n-rate
n=timer()
t=timer()
score#=calcScore(diff)*2
endfunction score#
function calcScore(proximity as integer)
score#=0
if (proximity<range) and (-proximity)<range then score#=1
endfunction score#