TGC Codebase Backup



Basic 3D Acceleration Engine by Doomwad

10th Feb 2004 16:09
Summary

A basic approach to acceleration and turning. Allows full and easy customization. Allows for textured/randomized matrix.



Description

Heavilly commented, studying it for a few seconds/minutes you can get how simple this is. You can use this in your games if you want. But if you do, a little bit of credit would be great. When you first run the program, the matrix will be a wireframe. Also, at the top of the code you will notice a lot of variables. Those are there so you won't have to go deep into the code in order to adjust simple things. This works well, allowing you to make minor adjustments easilly. If there are any errors, tell me and I will try to fix the bugs. And remember, this isn't supposed to be anything fancy. No AI, no models, no lighting, no objects even! Just a matrix, a camera, and a lot of variables. Enjoy! :^ )



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem -------------------------------------
rem + Author: Tyler Walker                                       
rem + Date: 2-10-04                                        
rem + Title: Acceleration Engine                                                      
rem +                                          
rem -------------------------------------
rem important variables
maxspeed = 100
turn = 2.0
sharpturn = 4.0
acceleration = 2
dacceleration = 1
minspeed = 0

rem basic neccesary stuff
sync on
speed = 0
hide mouse
backdrop on
rem load image " ", 1
rem texture backdrop 1


rem setup basic matrix
make matrix 1,10000.0,10000.0,25,25

rem below are the codes to make random, textured matrix. Just take
rem out the rems and put in a file name for the load image command
rem load image " ", 2
rem prepare matrix texture 1,2,2,2
rem randomize matrix 1,100.0

rem Position camera
position camera 5000,200,5000


rem Begin loop
do

rem set speed parameters
if speed < minspeed then speed = minspeed
if speed >= maxspeed then speed = maxspeed

rem move the camera based on speed variable
move camera speed

rem Control camera with arrow keys
if upkey()=1 then speed = speed + acceleration
if upkey()=0 then speed = speed - dacceleration
if downkey()=1 then speed = speed - 5
if leftkey()=1 and shiftkey()=1 then angley#=wrapvalue(angley#-sharpturn)
if rightkey()=1 and shiftkey()=1 then angley#=wrapvalue(angley#+sharpturn)
if leftkey()=1 then angley#=wrapvalue(angley#-turn)
if rightkey()=1 then angley#=wrapvalue(angley#+turn)

rem Update camera
xrotate camera 0.0
yrotate camera angley#
zrotate camera 0.0
y#=get ground height(1,x#,z#)+50.0

rem print basic info
set cursor 0,0
print "Controls: UP: move accelerate. DOWN: deceleterate. " 
print "Left: Turn left. Right: Turn Right."
print "Shift + turn keys: sharp turning."
rem print the information to be placed inside of the Heads Up Display (HUD)
set cursor 0,400
print "FPS: "; Screen FPS(); "  "; "Speed: "; speed

sync


loop