TGC Codebase Backup



cartoon game by How is it going

18th Aug 2007 13:18
Summary

It is a fun game that challenges you to try and get the key...



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem load sound
Load music "Oceans Apart.mid",1
loop music 1
Load sound "pop.wav",1
set sound pan 1,0
load sound "ping.wav",2
set sound pan 2,0
load sound "harp.wav",3
set sound pan 3,0

rem sync
sync on
sync rate 100
hide mouse

rem make a floor
make object box 1,1000,5,1000
color object 1,rgb(0,0,0)
position object 1,0,0,0
Load bitmap "grate02.bmp",1
get image 1,0,0,250,250
delete bitmap 1
texture object 1,1

rem load bitmap for player
load bitmap "iron03.bmp",2
get image 2,0,0,250,250
delete bitmap 2
make object sphere 2,20
texture object 2,2
position object 2,-400,15,-400
make object collision box 2,-10,-15,-10,10,15,10,0

rem make a world setting
load bitmap "up.jpg",3
get image 3,0,0,250,250
delete bitmap 3
backdrop on
texture backdrop 3

rem make objects
load bitmap "marble07.bmp",4
get image 4,0,0,250,250
delete bitmap 4
make object box 20,1000,200,200
position object 20,0,0,350
texture object 20,4
make object collision box 20,-500,-100,-100,500,100,100,0
make object box 21,1000,1,150
position object 21,0,100,350
color object 21,rgb(100,0,0)

rem Make four walls
Load bitmap "brick07.bmp",22
get image 22,0,0,250,250
delete bitmap 22
make object box 22,50,200,1000 : position object 22,-490,100,0 : texture object 22,22
make object box 23,50,200,1000 : position object 23, 490,100,0 : texture object 23,22
make object box 24,1000,200,50 : position object 24, 0,100,-490 : texture object 24,22
make object box 25,1000,200,50 : position object 25, 0,100, 490 : texture object 25,22
make object box 26,1000,50,500 : position object 26, 0,0,-250 : texture object 26,4
make object collision box 26,-500,-25,-250,500,25,250,0
Load bitmap "castle_carpet.bmp",5
get image 5,0,0,150,150
delete bitmap 5
texture object 21,5
Load bitmap "castle_wood1.bmp",6
get image 6,0,0,50,50
delete bitmap 6
texture object 26,6
texture object 20,22

rem pillars
make object cylinder 27,30
position object 27,390,30,190
scale object 27,90,200,90
texture object 27,4
make object cylinder 28,30
position object 28,400,30,130
scale object 28,90,200,90
texture object 28,4
make object cylinder 29,30
position object 29,420,30,70
scale object 29,90,200,90
texture object 29,4
make object box 30,150,10,400
texture object 30,22
position object 30,390,65,-177
make object collision box 27,-10,-20,-10,10,20,10,0
make object collision box 28,-10,-20,-10,10,20,10,0
make object collision box 29,-10,-20,-10,10,20,10,0
make object box 32,170,70,170
position object 32,378,50,-386
texture object 32,22

rem picture
load bitmap "picture.bmp",7
get image 7,0,0,250,250
delete bitmap 7
make object box 7,1,47,40
position object 7,290,50,-350
texture object 7,7

rem a railling
load bitmap "castle_wood.bmp",21
get image 21,0,0,50,50
delete bitmap 21
make object box 33,340,8,1
position object 33,200,105,250
make object collision box 33,-170,-4,-0.5,170,4,0.5,0 
make object box 34,450,8,1
position object 34,-260,105,250
make object collision box 34,-225,-4,-0.5,225,4,0.5,0 
texture object 33,6
texture object 34,6
make object box 35,340,8,10
position object 35,200,105,-350
make object collision box 35,-170,-4,-5,170,4,5,0 
texture object 35,21
make object box 36,340,8,10
position object 36,-150,105,-380
make object collision box 36,-170,-4,-5,170,4,5,0 
texture object 36,21

make object box 37,150,8,50
texture object 37,21
position object 37,-250,105,-400
make object collision box 37,-75,-4,-25,75,4,25,0
make object box 38,50,8,50
texture object 38,21
position object 38,-300,105,-300
make object collision box 38,-75,-4,-25,75,4,25,0
make object box 39,50,8,50
texture object 39,21
position object 39,-350,105,-200
make object collision box 39,-75,-4,-25,75,4,25,0
make object box 40,50,8,50
texture object 40,21
position object 40,-400,105,-200
make object collision box 40,-75,-4,-25,75,4,25,0
make object box 43,50,50,50
position object 43,-450,50,-200
make object collision box 43,-25,-25,-25,25,25,25,0
hide object 43
Load object "chest1.x",41
scale object 41,5000,5000,5000
position object 41,-400,120,-200
yrotate object 41,270
Load object "SKELKEY.X",42
scale object 42,10000,10000,10000
position object 42,-400,180,-200
hide object 42

rem Make the wall and floor objects into static objects (for auto-camera collision)
for t=22 to 25
	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
	make static object 32
	objx#=object position x(32)
	objy#=object position y(32)
	objz#=object position z(32)
	objsx#=object size x(32)/2.0
	objsy#=object size y(32)/2.0
	objsz#=object size z(32)/2.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
	delete object 32
	make static object 30
	objx#=object position x(30)
	objy#=object position y(30)
	objz#=object position z(30)
	objsx#=object size x(30)/2.0
	objsy#=object size y(30)/2.0
	objsz#=object size z(30)/2.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
	delete object 30

rem Make a pedestal steps
for t=3 to 9
	make object box 6+t,20,8,20
	position object 6+t,0,2+(t*10),-140+(t*50)
	color object 6+t,rgb(100,0,0)	
next t

rem Make the pedastal use non-rotated box collision
for t=3 to 9
	make object collision box 6+t,-8,-4,-8,8,4,8,0
next t

rem make static object
	make static object 1
	objx#=object position x(1)
	objy#=object position y(1)
	objz#=object position z(1)
	objsx#=object size x(1)/2.0
	objsy#=object size y(1)/2.0
	objsz#=object size z(1)/2.0
	make static collision box objx#-objsx#,objy#-objsy#,objz#-objsz#,objx#+objsx#,objy#+objsy#,objz#+objsz#
	delete object 1
 
rem Start off player gravity
playergrav#=2.0

rem loop
Do

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 move object 2,-1 
if downkey()=1 then move object 2,1 
if leftkey()=1 then yrotate object 2,wrapvalue(object angle y(2)-2)
if rightkey()=1 then yrotate object 2,wrapvalue(object angle y(2)+2)
if spacekey()=1 and playergrav#=0.0 then playergrav#=2.0 : play sound 1
if returnkey()=1
play sound 3 
show object 43
endif
if returnkey()=0
stop sound 3
hide object 43
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
posy#=posy#+playergrav#

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 Set a size for the player object
s#=object size y(2)/2.0

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 x(2)
camdist#=190.0 : camhigh#=posy#+150.0 : camfade#=3.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,10
point camera posx#,posy#,posz#

rem object
turn object left 42,5

rem win
if object collision(2,41)=1
stop music 1
play sound 2
wait (1000)
show object 42
wait key
end
endif

rem sync
sync

rem loop
loop