TGC Codebase Backup



Car Race by Car Race Game

8th Mar 2012 16:28
Summary

Collect the cubes. I need help with this.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on  
sync rate 60  
hide mouse  
autocam off  
randomize timer()  
cls  

REM Variables.
accl# = 0.2  
brak# = 0.2  
turn# = 2.0  
max_spd# = 3.0  
cam_ran = 30  
cam_hgt = 10  
cam_tip = 10  
fric# = 0.1  
f_time# = 999.9  
o_time# = f_time#  
scr = 0
sw = screen width()  
sh = screen height()  

do  
read w,d, x,z  
if w = 0  
exit  
endif  
inc ob  
h = 2*(rnd(100)+50)   
make object box ob, w,h,d  
color object ob, rgb(100,h,100)  
ghost object on ob  
position object ob, x,h/2,z  
loop

n_blk = ob  
do  
read x,z  
if x = 0  
exit  
endif  
inc ob  
inc m_scr  
make object cube ob, 10  
color object ob, rgb(255,255,100)  
xrotate object ob, 45  
zrotate object ob, 45  
fix object pivot ob  
position object ob, x,5,z  
loop

```````````````````````````````````````````````````````````````````````
REM This load the car and it's location...Do not change.
Load object "C:\Users\ROP\Desktop\Models\bentley.x",66,100,100
Position object 66,355,1,-195
```````````````````````````````````````````````````````````````````````

REM Main Variables...Do not change.
read xp#,zp#,face#  
inc ob  
make object cone ob, 100  
set object collision off ob  
color object ob, rgb(50,255,50)  
position object ob, xp#,50,zp#  
inc ob  
make object box ob,7,2,10  
position object ob, xp#,1,zp#  

REM Position car...Do not change.
do
o_xp# = object position x(ob)  
o_zp# = object position z(ob)  
o_face# = face#

REM Upkey is gas...Can change the =1.
if upkey() = 1
spd# = spd# + accl#  
endif  
for i = n_blk + 1 to ob - 1  
turn object left i,2  
next i  

REM Down key is brake...Can change the =1.
if downkey() = -1  
spd# = spd# - accl#
bst# = 0.0 
endif  

REM Turn left...Can change the =1.
if leftkey() = 1  
face# = wrapvalue(face# - turn#)  
endif  

REM Turn right..Can change the =1.
if rightkey() = 1  
face# = wrapvalue(face# + turn#)  
endif  

REM Space boost...Can change the =1...And +0.5.
if spacekey() = 5
bst# = bst# + 1
endif  
spd# = spd# + bst# - fric#  
bst# = bst# - fric#
bnc# = bnc# - 50000  
if spd# <= 0.0  
spd# = 0.0  
endif  
if spd# > max_spd#+bst#  
spd# = max_spd#+bst#  
endif  
if bst# > 5.0  
bst# = 5.0  
endif  
if bst# <= 0.0  
bst# = 0.0  
endif  
if bnc# <= 0.0  
bnc# = 0.0  
endif

REM this is all of the variables. And camera position...Do not change.
move object ob, spd# - bnc#  
yrotate object ob, face#  
set camera to follow object position x(66), cam_hgt, object position z(66), face#, cam_ran, cam_hgt, 5, 0  
`xrotate camera cam_tip  
ob_num = object collision(66,0)
if ob_num > 0 and ob_num =< n_blk  
bnc# = spd#*1.5  
spd# = 0.0  
position object 66, o_xp#, 1, o_zp#  
face# = o_face#  
endif  
if ob_num > n_blk  
inc scr  
hide object ob_num
set object collision off ob_num  
if scr = 1  
start_time# = timer()  
endif  
endif  
if scr > 0 and scr < m_scr  
time# = (timer() - start_time#)/1000.0  
endif  
if scr = m_scr  
if time# < f_time#
nft = 1  
f_time# = time#  
endif  

REM Restart game after finish.
if returnkey() = 1  
nft = 0  
for i = n_blk + 1 to ob - 2  
show object i  
set object collision on i  
scr = 0  
time# = 0.0  
next i  
endif  
endif  

set cursor 0,0
print screen fps()  
print "arrows keys to move, spacebar to boost"
print : print "CURRENT TIME : ", time# : print "FASTERT TIME : ", f_time# : 
print "CUBES COLLECTED : ", scr , " OF ", m_scr
if scr = m_scr
if nft = 0
center text sw/2, sh/2-75, "FINISHED"
else
center text sw/2, sh/2-75, "!! NEW FASTEST TIME !!"
endif
center text sw/2, sh/2-50, "PRESS ENTER TO RESET CUBES"
endif

```````````````````````````````````````````````````````````````````````
 `yrotate the car
   yrotate object 66,y
    
  `get keyboard input to change the y variable
   if rightkey()=1 then y=wrapvalue(y+2)
   if leftkey()=1 then y=wrapvalue(y-2)
 
   `move the object..And speed is the 0.5
   if upkey()=1 then move object 66,0.5
   if downkey()=1 then move object 66,0.5
 
   `yrotate the car
   yrotate object 66,y
 
 set camera to follow object position x(66),object position y(66),object position z(66),ang,3,8,5,10
   `point the car at the sphere
    xPoint#=object position x(66)
    yPoint#=object position y(66)
    zPoint#=object position z(66)
```````````````````````````````````````````````````````````````````````

sync
loop
data 100,300,250,150,  100,300,450,150,  100,100,650,250,  100,300,850,350,  100,200,1050,300,  100,180,1250,290,  80,80,1360,340,  220,100,210,450
data 160,100,420,450,  100,100,650,450,  100,100,1250,450,  180,100,1410,450,  100,200,1050,600,  340,100,170,650,  140,100,430,650,  100,100,650,650
data 100,180,850,690,  200,100,1220,650,  260,100,1470,650,  200,100,200,850,  300,300,550,950,  100,100,850,850,  140,100,1070,850,  180,100,1250,850
data 140,100,1430,850,  100,100,50,1050,  100,100,250,1050,  100,140,850,1070,  100,160,1050,1080,  100,100,1250,1050,  100,300,1450,1150,  100,140,850,1230
data 100,120,1050,1240,  100,300,150,1350,  200,100,400,1250,  100,160,650,1280,  100,100,1250,1250,  200,100,400,1450,  100,320,650,1540,  100,200,850,1500
data 300,100,1150,1450,  200,100,400,1650,  100,100,1050,1650, 0,0,0,0,    350,250,  350,650,  350,950,  350,1350,  850,1350,  1350,1250,  1050,1170,  850,950
data 950,550, 1310,390,  0,0,   350.0,-200.0,0.0