now with a better camera to see artistics,or seems so to me:p ;
Rem Project: Car1
Rem Created: 18.07.2004 16:20:27
Rem ***** Main Source File *****
`variables
rem Car Variables
Global car as Integer = 1
car_start_x_pos as Float = 25.0
car_start_y_pos as Float = 1.5
car_start_z_pos as Float = 5.0
car_start_x_ang as Float = 0.0
car_start_y_ang as Float = 0.0
car_start_z_ang as Float = 0.0
`-------------------------
Rem camera variables
cam_start_x_pos As Float = 25.0
cam_start_y_pos as Float = 3.0
cam_start_z_pos as Float = 0.0
cam_start_x_ang as Float = 0.0
cam_start_y_ang as Float = 0.0
cam_start_z_ang as Float = 0.0
`-------------------------
Rem Matrix variables
Global ground as Integer = 1
ground_texture_number as Integer = 1
ground_texture_aspect as Integer = 1
ground_texture_name as String = "ground.bmp"
ground_size_x as Integer = 2000
ground_size_z as Integer = 2000
ground_tile_x as Integer = 100
ground_tile_z as Integer = 100
`-------------------------
rem world variables
milisecond_start = timer()
#constant second_start = milisecond_start / 60
#constant minute_start = second_start / 60
#constant hour_start = minute_start / 60
Global Gravity# As Float = 0.000
Global GravityInc# As Float = 0.01
Global Friction# As Float = 0.001
Global Wind# As Float = 0.010
`-------------------------
Global Speed# As Float = 0.000
Global Accel# As Float = 0.000
Global Rpm# As Float = 0.000
Global WheelSize# As Float = 2.000
Global turnangle# As Float = 0.0
Global turnMaxR# As Float = 1.0
Global turnMaxL# As Float = -1.0
Global maxTR# As Float = 30.0
Global maxTL# As Float = -30.0
`-------------------------------------------------------------
rem load object
load object "porsche.x",car
perform checklist for object limbs car
position object car,car_start_x_pos, car_start_y_pos, car_start_z_pos
rotate object car,car_start_x_ang, car_start_y_ang, car_start_z_ang
car_size_x# as Float = object size x (car)
car_size_y# as Float = object size y (car)
car_size_z# as Float = object size z (car)
type Wheel
no As Integer
xpos As Float
ypos As Float
zpos As Float
xangle As Float
yangle As Float
zangle As Float
xsize As Float
ysize As Float
zsize As Float
endtype
`-------------------------
dim limb(4) As Wheel
FLW = 1
FRW = 4
STW = 7
BW = 8
`-------------------------
dim cars(2) As Wheel
player1 = 1
player2 = 2
`-------------------------------------------------------------
`-------------------------------------------------------------
rem make ground
make matrix ground, ground_size_x, ground_size_z, ground_tile_x, ground_tile_z
load image ground_texture_name,ground_texture_number
prepare matrix texture ground, ground_texture_number, ground_texture_aspect, ground_texture_aspect
set matrix height ground,5,10,40
set matrix height ground,6,10,40
set matrix height ground,5,9,30
set matrix height ground,6,9,30
set matrix height ground,5,8,15
set matrix height ground,6,8,15
set matrix height ground,5,11,50
set matrix height ground,6,11,50
set matrix height ground,5,12,30
set matrix height ground,6,12,30
set matrix height ground,5,13,15
set matrix height ground,6,13,15
update matrix ground
`-------------------------------------------------------------
`-------------------------------------------------------------
rem make camera and position
position camera cam_start_x_pos, cam_start_y_pos, cam_start_z_pos
rotate camera cam_start_x_ang, cam_start_y_ang, cam_start_z_ang
`-------------------------------------------------------------
Rem World Variables
Fog On : Fog Color rgb(0,0,100) : Fog Distance 2500
Backdrop On : Color Backdrop rgb(0,0,100)
sync rate 60 : sync on
do
gosub Game_Time
gosub Variables
gosub Player1_Controls
`-------------------------
Rem Camera Final positions
set camera to follow cars(1).xpos, cars(1).ypos, cars(1).zpos, cars(1).yangle, 20, camy#, 50, 1
point camera cars(1).xpos, cars(1).ypos, cars(1).zpos
camx# = camera position x()
camz# = camera position z()
camy# = get ground height (ground, camx#, camz#)+10
if cars(1).ypos > camy#
camx# = camx# + 2 : camy# = cars(1).ypos
endif
position camera camx#, camy#, camz#
`set camera to follow cars(1).xpos, cars(1).ypos, cars(1).zpos, cars(1).yangle, 20, 3, 10, 1
`-------------------------
gosub Information
sync
loop
`-------------------------------------------------------------
Variables:
`-------------------------
rem front left wheel
limb(1).xpos = limb position x (car,FLW)
limb(1).ypos = limb position y (car,FLW)
limb(1).zpos = limb position z (car,FLW)
limb(1).xangle = limb angle x (car,FLW)
limb(1).yangle = limb angle y (car,FLW)
limb(1).zangle = limb angle z (car,FLW)
`-------------------------
rem front right wheel
limb(2).xpos = limb position x (car,FRW)
limb(2).ypos = limb position y (car,FRW)
limb(2).zpos = limb position z (car,FRW)
limb(2).xangle = limb angle x (car,FRW)
limb(2).yangle = limb angle y (car,FRW)
limb(2).zangle = limb angle z (car,FRW)
`-------------------------
rem steering wheel
limb(3).xpos = limb position x (car,STW)
limb(3).ypos = limb position y (car,STW)
limb(3).zpos = limb position z (car,STW)
limb(3).xangle = limb angle x (car,STW)
limb(3).yangle = limb angle y (car,STW)
limb(3).zangle = limb angle z (car,STW)
`-------------------------
rem Back wheel
limb(4).xpos = limb position x (car,BW)
limb(4).ypos = limb position y (car,BW)
limb(4).zpos = limb position z (car,BW)
limb(4).xangle = limb angle x (car,BW)
limb(4).yangle = limb angle y (car,BW)
limb(4).zangle = limb angle z (car,BW)
`-------------------------
`-------------------------
rem front left wheel
cars(1).xpos = object position x (player1)
cars(1).ypos = object position y (player1)
cars(1).zpos = object position z (player1)
cars(1).xangle = object angle x (player1)
cars(1).yangle = object angle y (player1)
cars(1).zangle = object angle z (player1)
cars(1).xsize = object size x (player1)
cars(1).ysize = object size y (player1)
cars(1).zsize = object size z (player1)
return
`-------------------------------------------------------------
`-------------------------------------------------------------
Player1_Controls:
Rem Up or Down Left or Right Keys
if upkey() > 0 or downkey() > 0
if upkey() > 0
rpm# = rpm# + 0.5
if rpm# > 23.00 then rpm# = 23.00
endif
if downkey() > 0
rpm# = rpm# - 0.5
if rpm# < -23.00 then rpm# = -23.00
endif
else
if rpm# > 0.00 and OnGround > 0
dec rpm#, 0.2
if rpm# < 0.00 then rpm# = 0.00
endif
if rpm# < 0.00 and OnGround > 0
inc rpm#, 0.2
if rpm# > 0.00 then rpm# = 0.00
endif
endif
if leftkey() > 0 or rightkey() > 0
if leftkey() > 0
turnangle# = turnangle# - 0.1
if turnangle# < turnMaxL# then turnangle# = turnMaxL#
endif
if rightkey() > 0
turnangle# = turnangle# + 0.1
if turnangle# > turnMaxR# then turnangle# = turnMaxR#
endif
else
if turnangle# > 0.00
dec turnangle#, 0.1
if turnangle# < 0.00 then turnangle# = 0.00
endif
if turnangle# < 0.00
inc turnangle#, 0.1
if turnangle# > 0.00 then turnangle# = 0.00
endif
endif
`-------------------------
`-------------------------
if inkey$() = "q" then shift = 1
if inkey$() = "a" then shift = 2
if inkey$() = "w" then shift = 3
if inkey$() = "s" then shift = 4
if inkey$() = "e" then shift = 5
rem Acceleration thingy
if OnGround > 0
Accel# = rpm# / 20.0
if Accel# > 2.30 then Accel# = 2.30
endif
speed# = curvevalue (accel#, speed#, rpm# * 2)
if shift = 0
if speed# > 0.00 then speed# = 0.00
endif
if shift = 1
if speed# > 0.10 then speed# = 0.10
endif
if shift = 2
if speed# > 0.40 then speed# = 0.40
endif
if shift = 3
if speed# > 0.70 then speed# = 0.70
endif
if shift = 4
if speed# > 1.00 then speed# = 1.00
endif
if shift = 5
if speed# > 1.15 then speed# = 1.15
endif
if speed# < -0.40 then speed# = -0.40
`-------------------------
`-------------------------
rem limb (Wheels) rotation
limb(1).xangle = wrapvalue (limb(1).xangle + speed#)
limb(2).xangle = wrapvalue (limb(2).xangle + speed#)
limb(1).yangle = wrapvalue (limb(1).yangle + turnangle#)
limb(2).yangle = wrapvalue (limb(2).yangle + turnangle#)
if limb(1).yangle > maxTR# then limb(1).yangle = maxTR#
if limb(1).yangle < maxTL# then limb(1).yangle = maxTL#
if limb(2).yangle > maxTR# then limb(2).yangle = maxTR#
if limb(2).yangle < maxTL# then limb(2).yangle = maxTL#
rotate limb player1, FLW, limb(1).xangle, limb(1).yangle, limb(1).zangle
rotate limb player1, FRW, limb(2).xangle, limb(2).yangle, limb(2).zangle
`-------------------------
`-------------------------
Rem Cars Final positions
if speed# > 0.0
inc cars(1).yangle, limb(1).yangle/20
else
dec cars(1).yangle, limb(1).yangle/20
endif
if speed# > 0.0 or speed# < 0.0
if OnGround > 0
rotate object player1, cars(1).xangle, cars(1).yangle, cars(1).zangle
endif
endif
cars(1).xpos = newxvalue (cars(1).xpos, cars(1).yangle, speed#)
cars(1).zpos = newzvalue (cars(1).zpos, cars(1).yangle, speed#)
`cars(1).ypos = get ground height (ground, cars(1).xpos, cars(1).zpos) + car_start_y_pos
if cars(1).ypos =< get ground height (ground, cars(1).xpos, cars(1).zpos) + car_start_y_pos
OnGround = 1
else
OnGround = 0
endif
if OnGround > 0
Gravity# = 0.0
cars(1).ypos = curvevalue (get ground height (ground, cars(1).xpos, cars(1).zpos) + car_start_y_pos, cars(1).ypos, 0.2)
else
Gravity# = Gravity# + GravityInc# : cars(1).ypos = cars(1).ypos - Gravity#
endif
`-------------------------
Rem Limb positions
rem front left wheel (FLW)
limb(1).ypos = get ground height (ground, limb(1).xpos, limb(1).zpos)
rem front left wheel (FRW)
limb(2).ypos = get ground height (ground, limb(2).xpos, limb(2).zpos)
rem Back wheels (BW)
limb(4).ypos = get ground height (ground, limb(4).xpos, limb(4).zpos)
if OnGround > 0
`work out the different heights
frontLHeight#=get ground height(ground, limb(1).xpos, limb(1).zpos)
frontRHeight#=get ground height(ground, limb(2).xpos, limb(2).zpos)
frontHeight#=get ground height(ground, cars(1).xpos, cars(1).zpos)
backHeight#=get ground height(ground, limb(4).xpos, limb(4).zpos)
leftHeight#=get ground height(ground, limb(1).xpos, limb(1).zpos)
rightHeight#=get ground height(ground, limb(1).xpos, limb(1).zpos)
`work out tilt values
xAng#=curveangle((backHeight#-frontHeight#)*10,object angle x(1),3)
zAng#=curveangle((frontLHeight#-frontRHeight#)*10,object angle z(player1),3)
Rem Update object tilting to the ground
if speed# > 0.0 or speed# < 0.0
rotate object player1, xAng#, cars(1).yangle, zAng#
endif
endif
`-------------------------
position object player1, cars(1).xpos, cars(1).ypos, cars(1).zpos
return
`-------------------------------------------------------------
`-------------------------------------------------------------
Game_Time:
`-------------------------
rem set timer
milisecond = timer ()
second = milisecond / 60
minute = second / 60
hour = minute / 60
`-------------------------
current_milisecond = (milisecond - milisecond_start)
current_second = current_milisecond / 1000
current_minute = current_second / 60
current_hour = current_minute / 60
`-------------------------
return
`-------------------------------------------------------------
`-------------------------------------------------------------
Game_End_Time:
`-------------------------
`-------------------------
return
`-------------------------------------------------------------
`-------------------------------------------------------------
Information:
`-------------------------
rem information about car
set cursor 0,0
for t = 1 to 15
if limb exist(car,t) then print t, " ", limb name$ (car,t)
next t
`-------------------------
rem time
text_milisecond = current_milisecond mod 60
text_second = current_second mod 60
text_minute = current_minute mod 60
text_hour = current_hour mod 60
print "Game Start Time: ", text_hour, ":", text_minute, ":", text_second, ":", text_milisecond
print "Game End Time: ", end_hour, ":", end_minute, ":", end_second, ":", end_milisecond
`-------------------------
rem speed issues
print "rpm: ", rpm#
print "acceleration: ", accel#
print "speed: ", speed#
print "speed / accel: ", speed# / Accel#
print "turning angle: ", turnangle#
print "shift: ", shift
`-------------------------
set cursor screen width ()-250,0
print "FLW x angle: ", limb(1).xangle
set cursor screen width ()-250,20
print "FLW y angle: ", limb(1).yangle
set cursor screen width ()-250,40
print "FLW z angle: ", limb(1).zangle
set cursor screen width ()-250,50
print "---------------"
set cursor screen width ()-250,60
print "FLW x pos: ", limb(1).xpos
set cursor screen width ()-250,80
print "FLW y pos: ", limb(1).ypos
set cursor screen width ()-250,100
print "FLW z pos: ", limb(1).zpos
set cursor screen width ()-250,110
print "_______________"
set cursor screen width ()-250,130
print "FRW x angle: ", limb(2).xangle
set cursor screen width ()-250,150
print "FRW y angle: ", limb(2).yangle
set cursor screen width ()-250,170
print "FRW z angle: ", limb(2).zangle
set cursor screen width ()-250,180
print "---------------"
set cursor screen width ()-250,190
print "FRW x pos: ", limb(2).xpos
set cursor screen width ()-250,210
print "FRW y pos: ", limb(2).ypos
set cursor screen width ()-250,230
print "FRW z pos: ", limb(2).zpos
set cursor screen width ()-250,240
print "_______________"
set cursor screen width ()-250,260
print "player1 x angle: ", cars(1).xangle
set cursor screen width ()-250,280
print "player1 y angle: ", cars(1).yangle
set cursor screen width ()-250,300
print "player1 z angle: ", cars(1).zangle
set cursor screen width ()-250,310
print "---------------"
set cursor screen width ()-250,330
print "player1 x pos: ", cars(1).xpos
set cursor screen width ()-250,350
print "player1 y pos: ", cars(1).ypos
set cursor screen width ()-250,370
print "player1 z pos: ", cars(1).zpos
set cursor screen width ()-250,380
print "---------------"
set cursor screen width ()-250,390
print "player1 x size: ", cars(1).xsize
set cursor screen width ()-250,410
print "player1 y size: ", cars(1).ysize
set cursor screen width ()-250,430
print "player1 z size: ", cars(1).zsize
`-------------------------
`-------------------------
return
`-------------------------------------------------------------