Get in your hover car and race your way to the fastest time!!!!
Controls:
- Use the mouse to turn but you need to use it like a joystick, move it left to turn left and right to turn right but then move it back to the mid point to go straight.
- Left mouse button to accelerate quickly to the low speed
- Left mouse button and right mouse button together to accelerate to high speed but the acceleration is slower (think of it has high and low gears).
- Right mouse button to brake / reverse.
- You'll also slow down due to friction.
- If you hit the red walls, you'll bounce backward.
- Go through the green gates, each race is three laps, race to get the fastest time.
Needs to be run in 640x480 resolution as the turning controls use the mouse pisition and I've not adjusted it for different resolutions.
edit: the compressed code may not work for you, please try the expanded code below, thanks.
Short track:
sync on : sync rate 0 : hide mouse : set window off : set camera range 1,6000 : sw = screen width() : hsw# = sw/2 : sh = screen height() : hsh# = sh/2 : wh = 15 : ob = 0 : do : read xa,za,xb,zb : if xa = 0 and za = 0 and xb = 0 and zb = 0 : exit : endif : inc ob : _make_wall(ob,xa,za,xb,zb,wh) : set object collision to polygons ob : color object ob,rgb(175,0,0) : set object emissive ob, rgb(100,0,0) : loop : num_walls = ob : do : read xa,za,xb,zb
if xa = 0 and za = 0 and xb = 0 and zb = 0 : exit : endif : inc ob : _make_wall(ob,xa,za,xb,zb,wh) : set object collision to polygons ob : color object ob,rgb(0,255,0) : loop : num_gates = ob - num_walls : car_ob = ob+1 : make object box car_ob, 15,5,25 : read start_x,start_y,start_facing# : read max_laps : fastest_race_time# = 999.9 : fastest_lap_time# = 999.9 : wait 500 : do : race_time# = 0.0 : gates_hit = 0 : num_laps = 0 : restart = 0 : start_time# = 0.0 : facing# = start_facing# : spd# = 0.0 : for i = num_walls + 1 to ob : if i = num_walls + 1
set object emissive i, rgb(0,200,0) : set object collision on i : else : set object emissive i, rgb(0,10,0) : endif : show object i : next i : position object car_ob, start_x,10,start_y : repeat : current_time = timer() : loop_time = current_time - loop_start_time : if loop_time > 12 : loop_start_time = current_time : old_x# = object position x(car_ob) : old_y# = object position y(car_ob) : old_z# = object position z(car_ob) : if mouseclick() = 0 : spd# = curvevalue(0.0,spd#,70) : endif : if mouseclick() = 1 : spd# = curvevalue(15.0,spd#,30) : endif : if mouseclick() = 2 : spd# = curvevalue(-5.0,spd#,40) : endif : if mouseclick() = 3
spd# = curvevalue(25.0,spd#,95) : endif : if abs(spd#) < 0.05 : spd# = 0.0 : endif : turn# = 2.5*(mousex()-hsw#)/hsw# : facing# = wrapvalue(facing# + turn#) : rotate object car_ob, 0,0,0 : turn object right car_ob, facing# : roll object right car_ob, turn#*30 : move object car_ob, spd# : hit = object collision(car_ob,0) : if hit > 0 and hit <= num_walls : position object car_ob, old_x#, old_y#, old_z# : spd# = spd#*-1 : endif : if num_laps < max_laps : if start_time# <> 0 : race_time# = (current_time - start_time#)/1000.0 : endif : if hit > num_walls : inc gates_hit : set object collision off hit : set object emissive hit, rgb(0,10,0) : if hit < ob : set object collision on hit + 1
set object emissive hit+1, rgb(0,200,0) : if gates_hit = 1 and num_laps = 0 : start_time# = current_time : endif : else : set object collision on num_walls + 1 : set object emissive num_walls+1, rgb(0,200,0) : endif : endif : else : if restart = 0 : if race_time# < fastest_race_time# : fastest_race_time# = race_time# : finish_message$ = "!!! NEW FASTEST TIME !!!" : else : finish_message$ = "RACE OVER" : endif : endif : restart = 1 : for i = num_walls+1 to ob : set object collision off i : hide object i : next i : if mouseclick() = 0 : if spacekey() = 1 : restart = 2
endif : endif : endif : if gates_hit => num_gates : gates_hit = 0 : inc num_laps : endif : endif : position camera object position x(car_ob), object position y(car_ob), object position z(car_ob) : rotate camera 0,0,0 : turn camera right facing# : roll camera right turn#*30 : pitch camera up 90 : move camera 30 : pitch camera down 100 : move camera -0.25*spd#^2 - 80 : if restart = 1 : center text hsw#, hsh#-20, finish_message$ : center text hsw#, hsh#+20, "release lmb and rmb then press space to race again" : endif : set cursor 0,0 : print "mouse to turn, lmb fast accelerate / slow speed" : print "lmb+rmb slow accelerate / fast speed, rmb to brake / reverse" : print : print "SPEED : ", spd# : print "LAP : ", num_laps+1, " of ", max_laps
print "CURRENT TIME : ", race_time# : print "FASTEST TIME : ", fastest_race_time# : print "hit : ", hit : sync : until restart = 2 : loop : end
function _make_wall(ob,xa,za,xb,zb,wh) : make object triangle ob, xa,0,za, xb,0,zb, xa,wh,za : make object triangle ob+1, xa,wh,za, xb,wh,zb, xb,0,zb : make mesh from object 1,ob+1 : add limb ob,1,1 : delete mesh 1 : delete object ob+1 : set object cull ob, 0 : ghost object on ob : endfunction
function _reset_gates(minimum,maximum,exclude) : for i = minimum to maximum : if i <> exclude : set object collision on i : show object i : endif : next i : endfunction
data 0,476,0,2524, 0,2524,476,3000, 476,3000,1200,3000, 1200,3000,1800,3600, 1800,3600,2524,3600, 2524,3600,3000,3124, 3000,3124,3000,476, 3000,476,2524,0, 2524,0,476,0
data 476,0,0,476, 300,600,300,2400, 300,2400,600,2700, 600,2700,1324,2700, 1324,2700,1924,3300, 1924,3300,2400,3300, 2400,3300,2700,3000, 2700,3000,2700,600, 2700,600,2400,300
data 2400,300,600,300, 600,300,300,600, 0,0,0,0, 0,1500,300,1500, 2162,3300,2162,3600, 2700,1800,3000,1800, 1300,0,1300,300, 0,1100,300,1100, 0,0,0,0
data 150,1200,0.0,3
Long track:
sync on : sync rate 0 : hide mouse : set window off : set camera range 1,6000 : sw = screen width() : hsw# = sw/2 : sh = screen height() : hsh# = sh/2 : wh = 15 : ob = 0 : do : read xa,za,xb,zb : if xa = 0 and za = 0 and xb = 0 and zb = 0 : exit : endif : inc ob : _make_wall(ob,xa,za,xb,zb,wh) : set object collision to polygons ob : color object ob,rgb(175,0,0) : set object emissive ob, rgb(100,0,0) : loop : num_walls = ob : do : read xa,za,xb,zb
if xa = 0 and za = 0 and xb = 0 and zb = 0 : exit : endif : inc ob : _make_wall(ob,xa,za,xb,zb,wh) : set object collision to polygons ob : color object ob,rgb(0,255,0) : loop : num_gates = ob - num_walls : car_ob = ob+1 : make object box car_ob, 15,5,25 : read start_x,start_y,start_facing# : read max_laps : fastest_race_time# = 999.9 : fastest_lap_time# = 999.9 : wait 500 : do : race_time# = 0.0 : gates_hit = 0 : num_laps = 0 : restart = 0 : start_time# = 0.0 : facing# = start_facing# : spd# = 0.0 : for i = num_walls + 1 to ob : if i = num_walls + 1
set object emissive i, rgb(0,200,0) : set object collision on i : else : set object emissive i, rgb(0,10,0) : endif : show object i : next i : position object car_ob, start_x,10,start_y : repeat : current_time = timer() : loop_time = current_time - loop_start_time : if loop_time > 12 : loop_start_time = current_time : old_x# = object position x(car_ob) : old_y# = object position y(car_ob) : old_z# = object position z(car_ob) : if mouseclick() = 0 : spd# = curvevalue(0.0,spd#,70) : endif : if mouseclick() = 1 : spd# = curvevalue(15.0,spd#,30) : endif : if mouseclick() = 2 : spd# = curvevalue(-5.0,spd#,40) : endif : if mouseclick() = 3
spd# = curvevalue(25.0,spd#,95) : endif : if abs(spd#) < 0.05 : spd# = 0.0 : endif : turn# = 2.5*(mousex()-hsw#)/hsw# : facing# = wrapvalue(facing# + turn#) : rotate object car_ob, 0,0,0 : turn object right car_ob, facing# : roll object right car_ob, turn#*30 : move object car_ob, spd# : hit = object collision(car_ob,0) : if hit > 0 and hit <= num_walls : position object car_ob, old_x#, old_y#, old_z# : spd# = spd#*-1 : endif : if num_laps < max_laps : if start_time# <> 0 : race_time# = (current_time - start_time#)/1000.0 : endif : if hit > num_walls : inc gates_hit : set object collision off hit : set object emissive hit, rgb(0,10,0) : if hit < ob : set object collision on hit + 1
set object emissive hit+1, rgb(0,200,0) : if gates_hit = 1 and num_laps = 0 : start_time# = current_time : endif : else : set object collision on num_walls + 1 : set object emissive num_walls+1, rgb(0,200,0) : endif : endif : else : if restart = 0 : if race_time# < fastest_race_time# : fastest_race_time# = race_time# : finish_message$ = "!!! NEW FASTEST TIME !!!" : else : finish_message$ = "RACE OVER" : endif : endif : restart = 1 : for i = num_walls+1 to ob : set object collision off i : hide object i : next i : if mouseclick() = 0 : if spacekey() = 1 : restart = 2
endif : endif : endif : if gates_hit => num_gates : gates_hit = 0 : inc num_laps : endif : endif : position camera object position x(car_ob), object position y(car_ob), object position z(car_ob) : rotate camera 0,0,0 : turn camera right facing# : roll camera right turn#*30 : pitch camera up 90 : move camera 30 : pitch camera down 100 : move camera -0.25*spd#^2 - 80 : if restart = 1 : center text hsw#, hsh#-20, finish_message$ : center text hsw#, hsh#+20, "release lmb and rmb then press space to race again" : endif : set cursor 0,0 : print "mouse to turn, lmb fast accelerate to low speed" : print "lmb+rmb slow accelerate to high speed, rmb to brake / reverse" : print : print "SPEED : ", spd# : print "LAP : ", num_laps+1, " of ", max_laps
print "CURRENT TIME : ", race_time# : print "FASTEST TIME : ", fastest_race_time# : print "hit : ", hit : sync : until restart = 2 : loop : end
function _make_wall(ob,xa,za,xb,zb,wh) : make object triangle ob, xa,0,za, xb,0,zb, xa,wh,za : make object triangle ob+1, xa,wh,za, xb,wh,zb, xb,0,zb : make mesh from object 1,ob+1 : add limb ob,1,1 : delete mesh 1 : delete object ob+1 : set object cull ob, 0 : ghost object on ob : endfunction
function _reset_gates(minimum,maximum,exclude) : for i = minimum to maximum : if i <> exclude : set object collision on i : show object i : endif : next i : endfunction
data 0,3300,0,5824, 0,5824,776,6600, 776,6600,1939,6600, 1939,6600,2843,5700, 2843,5700,3922,5700, 3922,5700,4800,6578, 4800,6578,6000,6900, 6000,6900,7200,6578, 7200,6578,8078,5700
data 8078,5700,8400,4500, 8400,4500,8078,3300, 8078,3300,7200,2422, 7200,2422,6000,2100, 6000,2100,5400,2261, 5400,2261,4961,2700, 4961,2700,4679,3750, 4679,3750,4350,4079, 4350,4079,3900,4200
data 3900,4200,3450,4079, 3450,4079,3123,3750, 3123,3750,3000,3300, 3000,3300,3121,2850, 3121,2850,3450,2521, 3450,2521,4500,2239, 4500,2239,4939,1800, 4939,1800,5100,1200, 5100,1200,4939,600
data 4939,600,4500,161, 4500,161,3900,0, 3900,0,3300,161, 3300,161,2861,600, 2861,600,2579,1650, 2579,1650,2250,1979, 2250,1979,1800,2100, 1800,2100,1200,2100, 1200,2100,600,2261
data 600,2261,161,2700, 161,2700,0,3300, 150,3320,150,5762, 150,5762,838,6450, 838,6450,1877,6450, 1877,6450,2777,5550, 2777,5550,3984,5550, 3984,5550,4878,6444, 4878,6444,6000,6745
data 6000,6745,7122,6444, 7122,6444,7944,5622, 7944,5622,8245,4500, 8245,4500,7944,3382, 7944,3382,7122,2556, 7122,2556,6000,2255, 6000,2255,5478,2395, 5478,2395,5095,2778, 5095,2778,4814,3828
data 4814,3828,4428,4214, 4428,4214,3900,4355, 3900,4355,3372,4214, 3372,4214,2986,3828, 2986,3828,2845,3300, 2845,3300,2986,2772, 2986,2772,3372,2386, 3372,2386,4422,2105, 4422,2105,4805,1720
data 4805,1720,4945,1200, 4945,1200,4805,678, 4805,678,4422,295, 4422,295,3900,155, 3900,155,3378,295, 3378,295,2995,678, 2995,678,2714,1728, 2714,1728,2328,2114, 2328,2114,1820,2250
data 1820,2250,1220,2250, 1220,2250,682,2395, 682,2395,295,2778, 295,2778,150,3320, 0,0,0,0, 0,4662,150,4662, 3380,5700,3380,5550, 8245,4500,8400,4500, 3372,4214,3450,4079, 2579,1650,2714,1728
data 0,4462,150,4462, 0,0,0,0, 75,4562,0.0,3
Oh, one last thing, this may cause motion sickness.
Enjoy.