TGC Codebase Backup



Flying by Brk_oth

27th Apr 2006 4:30
Summary

Flying Demo. If you fly low, you get more points.



Description

Flying Demo. If you fly low, you get more points. Just a short code with moving, crashing and point system.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` ***************************************************
` ********* Flying Code Created By Brk_Oth **********
` ***************************************************

rem hide mouse and stuff
cls
hide mouse


rem create world
make matrix 1,3000.0,3000.0,50,50
load bitmap "floor1.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,2,2
randomize matrix 1,70

for a=10 to 45
	set matrix height 1,a,7,200.0
next a
for a=1 to 40
	set matrix height 1,a,12,200.0
next a
for a=12 to 20
	set matrix height 1,40,a,200.0
next a
for a=12 to 35
	set matrix height 1,45,a,200.0
next a
for a=20 to 45
	set matrix height 1,43,a,200.0
next a
for a=10 to 40
	set matrix height 1,35,a,200.0
next a
for a=10 to 40
	set matrix height 1,a,a,200.0
next a
for a=3 to 48
	for b=3 to 48
		if rnd(5)=4
			set matrix height 1,a,b,100+rnd(80)
		endif
	next b
next a

for a=2 to 5
	for b=2 to 5
		if rnd(3)=2
			set matrix height 1,a,b,rnd(70)-150
		endif
	next b
next a


for a=1 to 50
	set matrix height 1,0,a,200.0
	set matrix height 1,50,a,200.0
	set matrix height 1,a,0,200.0
	set matrix height 1,a,50,200.0
next a


update matrix 1


rem make plane and crash plane
make object box 1,0.01,0.01,0.01
ghost object on 1
load object "plane.x",2
yrotate object 2,180
glue object to limb 2,1,0

load object "crash.x",3
scale object 3,200,200,200
yrotate object 3,180
glue object to limb 3,1,0
hide object 3

rem variables
x#=100
z#=100
y#=100
move=1
points=0


sync on

rem game loop
do

	rem move
	if move=1
		x#=newxvalue(x#,a#,5) : z#=newzvalue(z#,a#,5)
		if upkey()=1 then y#=y#+1
		if downkey()=1 then y#=y#-1
		if leftkey()=1 then a#=wrapvalue(a#-1.0)
		if rightkey()=1 then a#=wrapvalue(a#+1.0)
	endif
	if y#>160 then y#=160
	position object 1,x#,y#,z#
	yrotate object 1,a#

	rem camera flys behind plane
	ca#=wrapvalue(curveangle(a#,ca#,40.0))
	cx#=newxvalue(x#,wrapvalue(ca#+180),30)
	cz#=newzvalue(z#,wrapvalue(ca#+180),30)
	cy#=y#+10
	position camera cx#,cy#,cz#
	yrotate camera wrapvalue(ca#)
	xrotate camera 10

	rem crash
	if y#<get ground height(1,x#,z#)
		move=0
		hide object 2
		show object 3
		crash=1
	endif

	rem start again
	if crash=1
		if returnkey()=1
			move=1
			x#=100
			y#=100
			z#=100
			a#=0
			ca#=0
			hide object 3
			show object 2
			crash=0
			if points>highscore then highscore=points
			points=0
		endif
	endif

	rem points (get more points for flying lower)
	if move=1
		if y#<150 then points=points+1
		if y#<130 then points=points+2
		if y#<110 then points=points+3
		if y#<90 then points=points+4
		if y#<70 then points=points+5
		if y#<50 then points=points+6
		if y#<30 then points=points+7
		if y#<10 then points=points+8
		if y#<0 then points=points+9
		if y#<-10 then points=points+10
	endif

	rem print points
	set cursor 10,10
	print "Points: ",points
	set cursor 10,30
	print "Highest So Far: ",highscore


	rem sync
	sync

rem repeat loop
loop