TGC Codebase Backup



car race by the green scar

11th Jan 2007 17:35
Summary

This is a basic 3d car race. The middle car is controlled by the user. It is a great base for further features.



Description

This code I wrote myself from start to finish. I wanted to write a complete game without borrowing code from tutorials. I like the way this game handles and the ease of adding more features.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `Car Race
`1/10/07
`by Nicholas Tello
cls
hide mouse
sync on
sync rate 60

`backdrop
backdrop on
color backdrop rgb(100,100,250)

`matrix
load image "tarmac01.bmp",1
make matrix 1,20000,20000,20,20
prepare matrix texture 1,1,1,1
position matrix 1,-500,-5,-500

`track
make object box 2,100,1,10000
position object 2,0,-5,5000
color object 2,rgb(100,100,100)

`light
set ambient light 20

`controlled car
load object "car04.x",1
yrotate object 1,180 : fix object pivot 1
load sound "brakes.wav",1

set camera fov 1

`rival cars
load object "CAR34.x",3
position object 3,-10,0,0
yrotate object 3,180 : fix object pivot 3
load object "CAR48.x",5
position object 5,10,0,0
yrotate object 5,90 : fix object pivot 5
color object 5,rgb(10,10,200)

`starting gate
load object "start_gate_mrealms.3ds",4
position object 4,0,0,100
scale object 4,30,30,30
color object 4,rgb(10,50,10)

`game loop
do
a=object position x(1)
b=object position y(1)
c=object position z(1)

`controls
if leftkey()=1 then turn object left 1,2 : play sound 1
if rightkey()=1 then turn object right 1,2 : play sound 1
if upkey()=1 then move object 1,4
if downkey()=1 then move object 1,-2

`rivals
move object 3,rnd(5)
move object 5,rnd(5)

`camera
set camera to follow a,b,c,0,10,2,5,1

sync
loop