Rem Project: Gt_Racer
Rem Created: 27/12/2005 12:05:37
 
Rem ***** Main Source File *****
rem
sync on : sync rate 60
`load object "race track.x", 2
`load image "gt4 works.jpg", 2 , 1
make matrix 1, 100, 100, 10, 10
 
`position object 2, 0, -3, 0
`load object "gt4.x", 1
make object cube 1, 10
show object 1
`texture object 1, 2
position object 1, 0, -3, 5
make camera 1
 
do
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
oldx#=x#
oldy#=y#
oldz#=z#
if upkey()=1 then xspeed#=sin(ay#)*30 : zspeed#=cos(ay#)*30
if downkey()=1 then xspeed#=sin(ay#)*-30 : zspeed#=cos(ay#)*-30
if rightkey()=1 then ay#=wrapvalue(ay#+2)
if leftkey()=1 then ay#=wrapvalue(ay#-2)
xspeed#=xspeed#*0.97
zspeed#=zspeed#*0.97
x#=x#+xspeed#
z#=z#+zspeed#
position object 1,x#,y#,z#
yrotate object 1,ay#
speed#=sqrt((x#-oldx#)^2+(y#-oldy#)^2+(z#-oldz#)^2)
Create_Speedometer(speed#,100,100,4,20,rgb(255,0,255),rgb(0,255,0))
ca#=curveangle(ay#,ca#,20.0)
cx#=x#-sin(ca#)*300
cz#=z#-cos(ca#)*300
cy#=curvevalue(y#+100,cy#,20.0)
position camera cx#,cy#,cz#
point camera x#,y#,z#
position camera 1,cx#,cy#,cz#
yrotate camera 1,wrapvalue(camera angle y(0)+180)
set camera to image 1,10,128,64
sprite 10,screen width()/2-64,30,10
sync
loop
 
Function create_speedometer(movespeed#,speedox,speedoy,speedow,speedl,col1,col2)
 
ink col1,0
line speedox,speedoy,speedox+sin(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedoy+cos(wrapvalue(int(360-movespeed#)+180))*(speedow/2)
line speedox,speedoy,speedox-sin(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedoy-cos(wrapvalue(int(360-movespeed#)+180))*(speedow/2)
line speedox+sin(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedoy+cos(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedox+sin(wrapvalue(int(360-movespeed#)+270))*speedl,speedoy+cos(wrapvalue(int(360-movespeed#)+270))*speedl
line speedox-sin(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedoy-cos(wrapvalue(int(360-movespeed#)+180))*(speedow/2),speedox+sin(wrapvalue(int(360-movespeed#)+270))*speedl,speedoy+cos(wrapvalue(int(360-movespeed#)+270))*speedl
ink col2,0
text speedox-(speedl*1.5),speedoy,"0"
text speedox,speedoy-(speedl*1.5),"90"
text speedox+(speedl*1.5),speedoy,"180"
text speedox,speedoy+(speedl*1.5),"270"
 
endfunction