set display mode 1024,768,32
hide mouse
hide light 0
set ambient light 20
make light 1
autocam off
color backdrop 0
randomize timer()
fog on
fog distance 1000
fog color 0
 
gosub make_textures
 
sync on
sync rate 25
 
gosub make_ship
gosub make_speedbar
gosub make_walls
gosub make_barriers
gosub make_lights
gosub make_checkpoints
 
set text font "arial"
set text size 30
ink rgb(80,80,250),0
 
startagain:
 
gosub initial_settings
gosub zoom_in
 
starttime=timer()
 
do
 
if numberofloops<30
  text screen width()/2-10,screen height()/2+10,"GO!"
  inc numberofloops
endif
 
position light 1,object position x(1),object position y(1)+20,object position z(1)
scroll object texture 9,0,-0.03
 
gosub countdown
gosub score
gosub move_enemies
gosub move_lights
gosub move_checkpoints
gosub control_ship
gosub wall_collision
gosub move_walls
gosub collision_with_objects
if countdown=<0 then gosub game_over
gosub adjust_speed_bar
gosub move_camera
text 0,0,str$(screen fps())
 
sync
loop
 
make_textures:
 
for colour=100 to 255
ink rgb(colour-30,colour-60,colour),0
line 0,colour,155,colour
next colour
get image 1,0,100,155,255
box 0,0,100,100,rgb(55,50,50),rgb(55,50,50),rgb(50,50,50),rgb(50,50,50)
get image 2,0,0,100,100
box 0,0,100,100,rgb(100,100,150),rgb(0,0,0),rgb(100,100,150),rgb(0,0,0)
get image 3,0,0,100,100
cls
ink rgb(255,0,0),0
box 0,0,10,10
ink 0,0
box 0,0,9,9
get image 4,0,0,10,10
cls
ink rgb(255,0,0),0
set text font "arial"
set text to bold
set text size 20
text 0,20,"CHECKPOINT"
get image 5,0,0,120,60
cls
ink rgb(0,0,255),0
box 0,0,10,10
ink 0,0
box 0,0,9,9
get image 7,0,0,10,10
get image 1000000,0,0,1,1
ink rgb(255,255,0),0
box 0,0,1,1
get image 2000000,0,0,1,1
cls
make object sphere 1000000,1,30,30
ghost object on 1000000
set object specular power 1000000,50
set object specular 1000000,rgb(200,200,200)
position light 1,0,-1,2
position object 1000000,0,0,3
texture object 1000000,2000000
a=int(screen width()/3.0)
b=int(screen height()/3.0)
c=int(screen width()*2/3.0)
d=int(screen height()*2/3.0)
make object sphere 2000000,0.3
position object 2000000,0,-0.2,3
ghost object on 2000000
sync
get image 20,a,b,c,d
delete object 1000000
delete object 2000000
cls
ink rgb(100,100,100),0
box 0,0,400,400
ink 0,0
for n=1 to 200
x=rnd(400)
y=rnd(400)
sizex=rnd(20)
sizey=rnd(20)
box x,y,x+sizex,y+sizey
next n
for n=1 to 200
ink rgb(200+rnd(50),200+rnd(50),200+rnd(50)),0
x=rnd(400)
y=rnd(400)
sizex=rnd(20)
sizey=rnd(20)
box x,y,x+sizex,y+sizey
next n
get image 30,0,0,400,400
cls
ink rgb(255,255,255),0
for n=1 to 100
x=rnd(600)
y=rnd(600)
sizex=rnd(3)+1
sizey=rnd(3)+1
box x,y,x+sizex,y+sizey
next n
get image 31,0,0,600,600
 
cls
ink rgb(100,100,100),0
box 0,0,200,200
ink rgb(120,120,120),0
for n=1 to 100
x=rnd(200)
y=rnd(200)
sizex=rnd(10)
sizey=rnd(10)
box x,y,x+sizex,y+sizey
next n
for n=1 to 100
ink rgb(100-rnd(50),100-rnd(50),100-rnd(50)),0
x=rnd(200)
y=rnd(200)
sizex=rnd(10)
sizey=rnd(10)
box x,y,x+sizex,y+sizey
next n
get image 40,0,0,200,200
 
return
 
make_ship:
 
make object sphere 1,0.8,20,20
make object sphere 2,1,20,20
scale object 2,110,60,300
glue object to limb 2,1,0
make object cone 3,1
scale object 3,105,250,50
xrotate object 3,90
glue object to limb 3,1,0
position object 3,0,0,1.3
make object cone 4,1.5
scale object 4,20,140,100
zrotate object 4,-75
xrotate object 4,-35
position object 4,0.85,0.2,-1
glue object to limb 4,1,0
make object cone 5,1.5
scale object 5,20,140,100
zrotate object 5,75
xrotate object 5,-35
position object 5,-0.85,0.2,-1
glue object to limb 5,1,0
make object cone 6,0.2
set object cull 6,0
scale object 6,100,100,100
xrotate object 6,90
position object 6,0,0,-1.5
glue object to limb 6,1,0
make object cone 7,0.5
scale object 7,20,140,100
zrotate object 7,-110
xrotate object 7,-40
position object 7,0.3,-0.05,-1.3
glue object to limb 7,1,0
make object cone 8,0.5
scale object 8,20,140,100
zrotate object 8,110
xrotate object 8,-40
position object 8,-0.3,-0.05,-1.3
glue object to limb 8,1,0
for object=3 to 8
texture object object,2
set object smoothing object,100
set object specular power object,1
set object specular object,rgb(100,100,155)
next object
texture object 1,1
set object specular power 1,1
set object specular 1,rgb(100,100,155)
texture object 2,2
ghost object on 1,4
make object cone 9,0.5
set object cull 9,0
xrotate object 9,90
ghost object on 9,5
texture object 9,4
scale object texture 9,1,2
set object texture 9,2,1
set object light 9,0
position object 9,0,-0.05,-15
scale object 9,400,6000,100
glue object to limb 9,1,0
set object collision on 1
for object=1 to 4
set object collision to boxes object
next object
 
 
return
 
make_speedbar:
 
make object plain 10,3.03,0.52
position object 10,0,-3.5,6.5
set object light 10,0
disable object zdepth 10
make object plain 11,3.0,0.5
position object 11,0,-3.5,6.495
set object light 11,0
disable object zdepth 11
texture object 11,1000000
make object plain 12,3.0,0.5
position object 12,0,-3.5,6.494
set object light 12,0
disable object zdepth 12
texture object 12,2000000
lock object on 10
lock object on 11
lock object on 12
return
 
make_walls:
 
`floor
make object plain 200,1000,1000
texture object 200,30
set object light 200,0
xrotate object 200,90
scale object texture 200,5,5
make object plain 300,20,1000
texture object 300,30
set object specular power 300,1
set object specular 300,rgb(200,200,200)
set object emissive 300,rgb(50,50,20)
scale object texture 300,5,5
xrotate object 300,90
position object 300,0,0.1,0
 
`left
for ob=5000 to 5050
`wallx#=30*sin(theta#)
`inc theta#,2
wallx#=rnd(5)
make object box ob,10,30+rnd(30),15+rnd(15)
position object ob,-30-wallx#,0,(ob-5000)*20
`set object light ob,0
texture object ob,40
next ob
wallx#=0
theta#=0
`right
for ob=6000 to 6050
`wallx#=30*sin(theta#)
`inc theta#,2
wallx#=rnd(5)
make object box ob,10,30+rnd(30),15+rnd(15)
position object ob,30+wallx#,0,(ob-6000)*20
`set object light ob,0
texture object ob,40
next ob
 
`stars
make object plain 402,5000,5000
position object 402,25,0,0
xrotate object 402,-90
set object light 402,0
texture object 402,31
scale object texture 402,10,10
position object 402,0,300,0
set object fog 402,0
`hide object 402
return
 
make_barriers:
 
numberofobjects=20
dim opponentspeed#(numberofobjects+20)
for object=20 to 20+numberofobjects
random=rnd(1)
if random=0 then x#=20+rnd(30):y#=1+rnd(3)
if random=1 then x#=1+rnd(8):y#=10
make object box object,x#,y#,rnd(20)
`make object box object,rnd(10)+1,rnd(10)+1,rnd(10)+1
`color object object,rgb(0,0,250)
texture object object,40
 
scale object texture object,0.5*x#/y#,0.1
`ghost object on object,2
`set object specular object,rgb(rnd(55),rnd(55),rnd(55))
`set object emissive object,rgb(rnd(255),rnd(255),rnd(255))
`set object fog object,0
set object collision on object
yrotate object object,180
position object object,rnd(40)-20,rnd(10),1000-rnd(1000)
opponentspeed#(object)=rnd(10)/10.0+0.4
next object
 
return
 
make_lights:
 
numberofsigns=99
sign=1
polarity=1
for object=100 to 100+numberofsigns
make object plain object,1,1
ghost object on object
texture object object,20
`set object light object,0
set object transparency object,5
`set object emissive object,rgb(255,255,255)
polarity=polarity*-1
position object object,10*polarity,10,sign*1000/numberofsigns
inc sign
next object
 
return
 
make_checkpoints:
 
make object box 2000,30,30,1
set object collision on 2000
texture object 2000,5
ghost object on 2000
set object transparency 2000,5
set object light 2000,0
make object box 2001,30,30,1
set object collision on 2001
hide object 2001
 
return
 
initial_settings:
 
position camera 0,15,-100
hide object 10
hide object 11
hide object 12
for object=20 to 20+numberofobjects
position object object,rnd(8)-4,rnd(8),1000-rnd(1000)
opponentspeed#(object)=rnd(10)/10.0+0.4
next object
position object 2000,0,4,2000
position object 2001,0,4,2800
position light 1,object position x(1),object position y(1)+20,object position z(1)
addedtocountdown=0
exclusionflag=0
addtime=0
crash=0
skid=0
restart=0
score=0
speed#=0
maxspeed#=0.25
numberofloops=0
hide object 9
position object 1,0,2,0
rotate object 1,0,0,0
 
return
 
zoom_in:
 
do
text screen width()/2-30,screen height()/2-20,"Get ready....."
position camera 0,curvevalue(4,camera position y(0),10),curvevalue(-6,camera position z(0),10)
if camera position z()>-6.1 then exit
sync
loop
show object 9
show object 10
show object 11
show object 12
position camera 0,4,-6
 
return
 
countdown:
 
time=(timer()-starttime)/1000
countdown=40-time+addedtocountdown
ink rgb(250,0,0),0
text screen width()/2-20,0,str$(countdown)
 
return
 
score:
 
ink rgb(80,80,250),0
text screen width()/2-20,30,"Score: "+str$(score)
 
return
 
move_enemies:
 
for object=20 to 20+numberofobjects
position object object,object position x(object),object position y(object),object position z(object)-speed#*30`+opponentspeed#(object)
if object position z(object)<0
  position object object,rnd(50)-25,rnd(10),1000
  if crash=0 and skid=0
    inc score
  endif
endif
if object position z(object)>1000 then position object object,4,6,0
next object
 
return
 
move_lights:
 
for object=100 to 100+numberofsigns
position object object,object position x(object),object position y(object),object position z(object)-speed#*30
if object position z(object)<0 then position object object,object position x(object),object position y(object),1000
if object position z(object)>1000 then position object object,object position x(object),object position y(object),0
next object
 
return
 
move_checkpoints:
 
for object=2000 to 2001
position object object,object position x(1),object position y(1),object position z(object)-speed#*30
if object position z(object)<-50 then position object object,object position x(object),object position y(object),2500
next object
 
return
 
control_ship:
 
if shiftkey()=1 and speed#<maxspeed# then inc speed#,0.0005
if controlkey()=1 and speed#>0 then dec speed#,0.0005
xmousemove#=0
ymousemove#=0
if rightkey()=1 then xmousemove#=.5
if leftkey()=1 then xmousemove#=-.5
if upkey()=1 then ymousemove#=-.5
if downkey()=1 then ymousemove#=.5
 
 
if speed#>0
  speedy#=curvevalue(ymousemove#,speedy#,10)
  speedx#=curvevalue(xmousemove#,speedx#,10)
  xrotate object 1,curveangle(-ymousemove#*80,object angle x(1),10)
  zrotate object 1,curveangle(-xmousemove#*80,object angle z(1),10)
endif
if xmousemove#=0
  zrotate object 1,curveangle(0,object angle z(1),20)
  speedx#=curvevalue(0,speedx#,20)
endif
if ymousemove#=0
  xrotate object 1,curveangle(0,object angle x(1),20)
  speedy#=curvevalue(0,speedy#,20)
endif
 
if crash=0
position object 1,object position x(1)+speedx#,object position y(1)+speedy#,0
endif
 
return
 
wall_collision:
 
if object position x(1)<-22 then position object 1,-22,object position y(1),object position z(1)
if object position x(1)>22 then position object 1,22,object position y(1),object position z(1)
if object position y(1)<0 then position object 1,object position x(1),0,object position z(1)
if object position y(1)>10 then position object 1,object position x(1),10,object position z(1)
 
return
 
move_walls:
 
scroll object texture 200,0,speed#/5
scroll object texture 300,0,speed#/5
`scroll object texture 400,speed#/5,0
`scroll object texture 401,speed#/5,0
`scroll object texture 402,0,0.01
for object=5000 to 5050
position object object,object position x(object),object position y(object),object position z(object)-speed#*30`+opponentspeed#(object)
if object position z(object)<0
  position object object,-30-rnd(5),object position y(object),object position z(object)+1000
endif
next object
 
for object=6000 to 6050
position object object,object position x(object),object position y(object),object position z(object)-speed#*30`+opponentspeed#(object)
if object position z(object)<0
  position object object,30+rnd(5),object position y(object),object position z(object)+1000
endif
next object
 
return
 
collision_with_objects:
 
for test=1 to 4
collisionnumber=object collision(test,0)
if collisionnumber>=20 and collisionnumber<=20+numberofobjects and crash=0
   skid=1
   crash=1
   hide object 9
   yspeed#=speed#/1.5
   gravity#=0.002
   spin#=speed#*50.0
   goto getout
endif
next test
getout:
`collision with checkpoint
if object position z(1)>object position z(2000) and object position z(1)<object position z(2001) then addtime=1
if addtime=1 and exclusionflag=0
  inc addedtocountdown,20
  exclusionflag=1
endif
`collision with checkpoint reset point
if object position z(1)>object position z(2001) and exclusionflag=1 then exclusionflag=0:addtime=0
if skid=1
   rotate object 1,curveangle(-40,object angle x(1),15),object angle y(1)-spin#,curveangle(90,object angle z(1),10)
   position object 1,object position x(1),object position y(1),0
   if speed#<=0
     restart=1
     skid=0
     speed#=0
     crash=0
     position object 1,object position x(1),1,0
   endif
endif
if crash=1
   position object 1,object position x(1),object position y(1)+yspeed#,object position z(1)
   dec yspeed#,gravity#
   if object position y(1)<=1
     position object 1,object position x(1),1,0
     yspeed#=yspeed#*-0.4
     dec speed#,0.1
   endif
endif
if restart=1
   show object 9
   rotate object 1,0,0,0
   restart=0
endif
 
return
 
game_over:
 
  text screen width()/2-30,screen height()/2-20,"Game Over"
  sync
  wait 2000
  text screen width()/2-100,screen height()/2+20,"Press any key to restart"
  sync
  wait key
  goto startagain
 
return
 
adjust_speed_bar:
 
scale object 12,100*speed#/maxspeed#,100,100
position object 12,-1.5*(1.0-(speed#/maxspeed#)),object position y(12),object position z(12)
 
return
 
move_camera:
 
position camera curvevalue(object position x(1),camera position x(),5),curvevalue(object position y(1)+1,camera position y(),10),-6
 
return