TGC Codebase Backup



My game by How is it going

6th Jul 2007 18:56
Summary

Ok it's not done but I think it's pretty cool. It is the first game I have ever made that is animated, so the guy runs kind of funny. If you have any comments to tell me make it be



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem start
START:
rem load sounds
load sound "reload.wav",1
load sound "rain.wav",2
loop sound 2
Load sound "moan.wav",3
Load sound "lock.wav",4

rem mouse hide
hide mouse : sync rate 60
sync on

rem print 
set cursor 180,230
print "Gibson, a terrorist group called 'Slash' has recently devoloped a"
set cursor 180,245
print "new weapon much like the AK-47. The NSA would like you to bring it"
set cursor 180,260
Print "in for some testing. We will be waiting for you, Gibson." 
suspend for key

rem fog
fog on
fog distance 140
fog color rgb(30,30,30)

rem light
make light 1
position light 1,0,10,0
set light range 1,100
show light 1

rem Make a matrix
make object box 1,500,10,500
load bitmap "pave05.bmp",1
get image 1,0,0,250,250 : mirror bitmap 1 : delete bitmap 1 : texture object 1,1

rem Make four walls
make object box 12,10,25,500 : position object 12,-150,10,0 : color object 12,rgb(155,40,20)
load bitmap "concre03.bmp",12
get image 12,0,0,250,250 : mirror bitmap 12 : delete bitmap 12 : texture object 12,12
make object box 13,10,25,500 : position object 13, 150,10,0 : color object 13,rgb(155,40,20)
load bitmap "concre03.bmp",13
get image 13,0,0,250,250 : mirror bitmap 13 : delete bitmap 13 : texture object 13,13
make object box 14,500,25,10 : position object 14, 0,10,-150 : color object 14,rgb(155,40,20)
load bitmap "concre03.bmp",14
get image 14,0,0,250,250 : mirror bitmap 14 : delete bitmap 14 : texture object 14,14
make object box 15,500,25,10 : position object 15, 0,10,150 : color object 15,rgb(155,40,20)
load bitmap "concre03.bmp",15
get image 15,0,0,250,250 : mirror bitmap 15 : delete bitmap 15 : texture object 15,15
rem tall walls
make object box 16,10,200,500 : position object 16,-152,95,0 : color object 16,rgb(155,40,20)
load bitmap "window04.bmp",16
get image 16,0,0,255,255 : mirror bitmap 16 : delete bitmap 16 : texture object 16,16
make object box 17,10,200,500 : position object 17, 152,95,0 : color object 17,rgb(155,40,20)
load bitmap "window04.bmp",17
get image 17,0,0,255,255 : mirror bitmap 17 : delete bitmap 17 : texture object 17,17
make object box 18,500,200,10 : position object 18, 0,95,-152 : color object 18,rgb(155,40,20)
load bitmap "window04.bmp",18
get image 18,0,0,255,255 : mirror bitmap 18 : delete bitmap 18 : texture object 18,18
make object box 19,500,200,10 : position object 19, 0,95,152 : color object 19,rgb(155,40,20)
load bitmap "window04.bmp",19
get image 19,0,0,255,255 : mirror bitmap 19 : delete bitmap 19 : texture object 19,19
make object box 21,20,2.5,40 : position object 21,-142,25,0
load bitmap "concre03.bmp",21
get image 21,0,0,255,255 : mirror bitmap 21 : delete bitmap 21 : texture object 21,21
make object box 22,0.5,15,10 : position object 22,-142,13.5,0
load bitmap "water03.bmp",22
get image 22,0,0,250,250 : mirror bitmap 22 : delete bitmap 22 : texture object 22,22
Make object box 23,1,20,35
load bitmap "concre03.bmp",23
get image 23,0,0,255,255 : mirror bitmap 23 : delete bitmap 23 : texture object 23,23 : position object 23,-142.5,13.5,0
Load object "Tree2.x",24 : position object 24,-135,10,25 : scale object 24,550,550,550
Load object "Tree2.x",25 : position object 25,-126,10,-18 : scale object 25,550,550,550
rem make green
Make object box 28,30,0.5,120 : position object 28,-136.5,5.2,-72
load bitmap "grass15.bmp",28
get image 28,0,0,250,250 : mirror bitmap 28 : delete bitmap 28 : texture object 28,28
Make object box 29,30,0.5,120 : position object 29,-136.5,5.2,72
load bitmap "grass15.bmp",29
get image 29,0,0,250,250 : mirror bitmap 29 : delete bitmap 29 : texture object 29,29
rem make entrance bushes
Load object "Tree6.x",26 : position object 26,-140,5,10 : scale object 26,500,500,500
Load object "Tree6.x",27 : position object 27,-140,5,-10 : scale object 27,500,500,500
rem Make some objects
make object cylinder 30,150
scale object 30,0.5,25,0.5
make object sphere 31,5
color object 31,rgb(255,255,0)
ghost object on 31
position object 31,-1,24,-18
position object 30,-1,5,-18
rem light 1
make object cylinder 32,150
scale object 32,0.5,25,0.5
make object sphere 33,5
color object 33,rgb(255,255,0)
ghost object on 33
position object 33,-126,24,-10
position object 32,-126,5,-10
rem light 2
make object cylinder 34,150
scale object 34,0.5,25,0.5
make object sphere 35,5
color object 35,rgb(255,255,0)
ghost object on 35
position object 35,-126,24,10
position object 34,-126,5,10
rem a gate
Load object "pickgate.x",36 : position object 36,0,20,-145
scale object 36,4350,2700,4350 
make object cylinder 37,50 : xrotate object 37,90
color object 37,rgb(0,0,0) : position object 37,0,10,-170
rem car
LOAD OBJECT "H-taxi-move.3ds",38
position object 38,-80,5,-120 : scale object 38,550,550,550
make static object 38
	objx#=object position x(38)
	objy#=object position y(38)
	objz#=object position z(38)
	objsx#=object size x(38)/90.0
	objsy#=object size y(38)/2.0
	objsz#=object size z(38)/1.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#

rem Make the wall and floor objects into static objects (for auto-camera collision)
for t=12 to 15	
make static object t
	objx#=object position x(t)
	objy#=object position y(t)
	objz#=object position z(t)
	objsx#=object size x(t)/2.0
	objsy#=object size y(t)/2.0
	objsz#=object size z(t)/2.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
delete object t
next t

rem Make the wall and floor objects into static objects (for auto-camera collision)
	make static object 1
	objx#=object position x(1)
	objy#=object position y(1)
	objz#=object position z(1)
	objsx#=object size x(1)/10.0
	objsy#=object size y(1)/10.0
	objsz#=object size z(1)/10.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#

rem make object player
LOAD object "MAN2.X",2
position object 2,15,11,15
make object collision box 2,-5,-5,-5,5,5,5,0

rem Clear any animation in model
clear all object keyframes 2

rem Set last frame of animation back to first position
rotate limb 2,5,330,0,0 : rotate limb 2,2,30,0,0 : set object keyframe 2,0

rem Move limbs to new wave position and set keyframe 
rotate limb 2,5,330,0,0 : rotate limb 2,2,30,0,0 : set object keyframe 2,5
rotate limb 2,5,330,0,0 : rotate limb 2,2,30,0,0 : set object keyframe 2,4

rem Set last frame of animation back to first position
rotate limb 2,5,30,0,0 : rotate limb 2,2,330,0,0 : set object keyframe 2,8
rotate limb 2,5,30,0,0 : rotate limb 2,2,330,0,0 : set object keyframe 2,10
rotate limb 2,5,0,0,0 : rotate limb 2,2,0,0,0 : set object keyframe 2,11

rem save animation
save object animation "walk.dat",2

rem Find out how many limbs the object has
perform checklist for object limbs 2
numberoflimbs=checklist quantity()

rem Start off player gravity
playergrav#=2.0

rem load a weapon
load object "H-AK47-static.3ds",3
position object 3,8.5,12.3,-10
scale object 3,550,550,550
zrotate object 3,90
yrotate object 3,345

rem make a crate for gun object to sit on
Make object cube 4,6
load bitmap "crate3.jpg",2
get image 2,0,0,53,53 : delete bitmap 2 : texture object 4,2
position object 4,0,9,-10
Make object cube 5,6
load bitmap "crate3.jpg",3
get image 3,0,0,53,53 : delete bitmap 3 : texture object 5,3
position object 5,7,9,-10

rem load object enemy
Load object "man2.x",6
load bitmap "head.2.bmp",9	
get image 9,0,0,253,253 : delete bitmap 9 : texture limb 6,16,9
clear all object keyframes 6
rotate limb 6,6,325,0,0 : set object keyframe 6,0
rotate limb 6,6,0,0,0 : set object keyframe 6,5
rotate limb 6,5,7,0,0 : set object keyframe 6,15
rotate limb 6,5,0,0,0 : set object keyframe 6,25
rotate limb 6,3,315,0,0 : set object keyframe 6,65
rotate limb 6,3,0,0,0 : set object keyframe 6,70
rotate limb 6,2,6,0,0 : set object keyframe 6,80
rotate limb 6,2,0,0,0 : set object keyframe 6,85
loop object 6
make static object 6
	objx#=object position x(6)
	objy#=object position y(6)
	objz#=object position z(6)
	objsx#=object size x(6)/16.0
	objsy#=object size y(6)/26.0
	objsz#=object size z(6)/6.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
position object 6,7,11,-30
Make object cube 7,6
load bitmap "crate3.jpg",4
get image 4,0,0,53,53 : delete bitmap 4 : texture object 7,4
position object 7,7,9,-17
Make object cube 8,6
load bitmap "crate3.jpg",8
get image 8,0,0,53,53 : delete bitmap 8 : texture object 8,8
position object 8,7,15,-17
Make object cube 20,6
load bitmap "crate3.jpg",20
get image 20,0,0,53,53 : delete bitmap 20 : texture object 20,20
position object 20,-6,9,-17

rem make a chair
Load object "chair13.x",10
position object 10,-7,8,-9
scale object 10,650,650,650
Load object "pager.x",11
position object 11,-7,12.5,-15
scale object 11,1050,1060,1050
rem make an enemy for chair
Load object "man2.x",9
load bitmap "head.2.bmp",10	
get image 10,0,0,253,253 : delete bitmap 10 : texture limb 9,16,9
clear all object keyframes 9
position object 9,-7,9,-9
rotate limb 9,2,110,0,0 : rotate limb 9,5,110,0,0
rotate limb 9,3,270,0,0 : rotate limb 9,6,270,0,270
rotate limb 9,8,20,0,0 : rotate limb 9,15,15,0,0
rotate limb 9,15,0,0,0 : set object keyframe 9,0
rotate limb 9,15,0,70,0 : set object keyframe 9,15
rotate limb 9,15,0,0,0 : set object keyframe 9,20
rotate limb 9,15,0,300,0 : set object keyframe 9,35
rotate limb 9,15,0,0,0 : set object keyframe 9,40
rotate limb 9,15,5,0,0 : set object keyframe 9,45
loop object 9

rem Make the wall and floor objects into static objects (for auto-camera collision)
	make static object 4
	objx#=object position x(4)
	objy#=object position y(4)
	objz#=object position z(4)
	objsx#=object size x(4)/10.0
	objsy#=object size y(4)/10.0
	objsz#=object size z(4)/10.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#

rem set backdrop
backdrop on
color backdrop 0 : Load bitmap "up.jpg",6 : get image 6,0,0,5,5 : delete bitmap 6 : texture backdrop 6

rem loop
DO

rem sync 
sync

rem Store old positions
oldposx#=object position x(2)
oldposy#=object position y(2)
oldposz#=object position z(2)

rem Control player object
if upkey()=1 then loop object 2 : move object 2,-0.5
if leftkey()=1 then yrotate object 2,wrapvalue(object angle y(2)-1.5)
if rightkey()=1 then yrotate object 2,wrapvalue(object angle y(2)+1.5)
if upkey()=0 then stop object 2 : rotate limb 2,5,0,0,0 : rotate limb 2,2,0,0,0 : rotate limb 2,9,0,0,0 : rotate limb 2,12,0,0,0 
if upkey()=0 and downkey()=1 
	loop object 2 : move object 2,0.5
endif
if object collision(2,3)=1 and spacekey()=1
   delete object 3 : play sound 1
	clear all object keyframes 6
	yrotate object 6,90	: set object keyframe 6,0
	yrotate object 6,195 : set object keyframe 6,15
   play object 6
	wait (1000)
end
endif
rem death
death:
rem death
if object collision(2,6)=1 and spacekey()=1
clear all object keyframes 6
stop object 2
rotate limb 6,3,330,0,0 : rotate limb 6,6,330,0,0 : set object keyframe 6,0   
rotate limb 6,3,270,0,0 : rotate limb 6,6,270,0,0 : set object keyframe 6,15
position object 6,7,10,-30 : set object keyframe 6,14
rotate limb 6,1,270,0,0 : position object 6,7,7,-30 : rotate limb 6,3,0,0,0 : rotate limb 6,6,0,0,0 : position object 6,7,7,-30 : rotate limb 6,15,0,90,0 : set object keyframe 6,25
play object 6 : play sound 3
wait (5000)
delete object 6
endif
rem if death
if object exist(6)=0 and object collision(2,3)>0 
   stop object 2
   suspend for key
	delete object 3 : play  sound 1
endif
rem c/enemy
if object collision(2,9)=1 and spacekey()=1
clear all object keyframes 9
stop object 2
rotate limb 9,15,0,0,0 : set object keyframe 9,0
rotate limb 9,15,20,0,0 : set object keyframe 9,8
play object 9 : play sound 3
wait (1000)
delete object 9
endif
rem if c/death
if object exist(6)=0 and object exist(9)=0 and object collision(2,3)>0 
   stop object 2
	suspend for key
	delete object 3 : play  sound 1
endif
rem if c/death before enemy
if object exist(6)=0 and object exist(9)=1  
point camera -7,9,-9
stop object 2
clear all object keyframes 9
rotate limb 9,8,345,0,0 
rotate limb 9,15,0,0,0 : set object keyframe 9,0
rotate limb 9,15,5,0,0 : rotate limb 9,15,0,15,0 : set object keyframe 9,5
rotate limb 9,9,145,0,0 : set object keyframe 9,10
rotate limb 9,9,0,0,0 : rotate limb 9,15,5,0,0 : set object keyframe 9,15  
loop object 9 
wait (1000)
end
endif

rem chair 
if object exist(9)=0 and object collision(2,10)>0 and spacekey()=1
	rotate object 10,200,0,0 : set object keyframe 10,0
	rotate object 10,250,0,0 : position object 10,-7,8,-10 : set object keyframe 10,5
	rotate object 10,275,0,0 : set object keyframe 10,10
play object 10
endif

rem succses
if object exist(3)=0
	cls
	set cursor 266,240
   print "Good work agent." 
	set cursor 271,270
	print "Return to base."
suspend for key 
end
endif

rem Get current object position
posx#=object position x(2)
posy#=object position y(2)
posz#=object position z(2)

rem Handle a touch of gravity
playergrav#=playergrav#-0.1

rem Handle sliding collision for player object with other objects
position object 2,posx#,posy#,posz#
if object collision(2,0)>0
	dec posx#,get object collision x()
	dec posy#,get object collision y()
	dec posz#,get object collision z()
	playergrav#=0.0
endif

rem Ensure camera stays out of static collision boxes
if get static collision hit(oldposx#-s#,oldposy#-s#,oldposz#-s#,oldposx#+s#,oldposy#+s#,oldposz#+s#,posx#-s#,posy#-s#,posz#-s#,posx#+s#,posy#+s#,posz#+s#)=1
	dec posx#,get static collision x()
	dec posy#,get static collision y()
	dec posz#,get static collision z()	
	if get static collision y()<>0.0 then playergrav#=0.0
endif

rem Update with new object position
position object 2,posx#,posy#,posz#

rem Use camera tracker to follow player object
angle#=object angle y(2)
camdist#=-15.0 : camhigh#=posy#+6.0 : camfade#=3.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1 

rem Set a size for the player object
s#=object size y(2)/1.0

rem sync
sync

rem loop
LOOP