Box Maze by Daygamer20th May 2008 12:40
|
---|
Summary Escape out of the Maze of Boxes. No Media! Description Hey, all! This is a little game I made that uses very efficient code to make a little maze game. I think the code is efficient because usually my code is not very efficient at all! lol! The object is to reach any edge of the square platform that you start out on. There are lots of randomly placed boxes that you must navigate through. You can use the SHIFT key to view the overhead view, which can be very useful to see what's ahead. After you complete a level the program adds more boxes until you can hardly move. You don't need any files to run my program! Give it a try. God Bless! Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com hide mouse ink rgb,(0) ES = 1 N = 1 sync on : sync rate 60 make object box 1,1,1,1 make object box 65535,1000,0,1000 position object 65535,500,-0.5,500 set object collision off 65535 make object box 65534,1000,10,10 position object 65534,500,0,1000 make object box 65533,1000,10,10 position object 65533,500,0,0 make object box 65532,10,10,1000 position object 65532,0,0,500 make object box 65531,10,10,1000 position object 65531,1000,0,500 color object 65535,rgb(100,100,100) hide object 65534 hide object 65533 hide object 65532 hide object 65531 levelstart: Level = Level+1 ES = ES+1000 do N = N+1 make object box N,10,10,10 position object N,rnd(1000),0,rnd(1000) if N = ES or N > ES then goto mainloop Position Camera 500,500,500 Point camera 500,0,500 set cursor 10,10 X = ES-N print X," cubes left to make." set cursor 550,10 print "Level ",Level sync loop rem mainloop mainloop: color object 1,rgb(rnd(1000),rnd(1000),rnd(1000)) position object 1,rnd(1000),0,rnd(1000) if object collision(1,0) then position object 1,rnd(1000),0,rnd(1000) do rem Store old positions oldposx# = object position x(1) oldposy# = object position y(1) oldposz# = object position z(1) rem controls if SH# < 0.5 then if upkey()=1 then SH# = SH#+0.049 if SH# > -0.5 then if downkey()=1 then SH# = SH#-0.049 if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-3) if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+3) if spacekey()=1 and playergrav#=0 then playergrav#=0.4 move object 1,SH# if SH# > 0 then SH# = SH#-0.001 if SH# < 0 then SH# = SH#+0.001 rem get current object position posx#=object position x(1) posy#=object position y(1) posz#=object position z(1) position object 350,posx#,posy#+playergrav#-2,posz# rem gravity playergrav#=playergrav#-0.01 posy#=posy#+playergrav# rem sliding collision position object 1,posx#,posy#,posz# if object collision(1,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 size for controled object s#=object size y(1)/2.0 rem Ensure camera stays out of static 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 if get static collision y()<>0.0 then if SH# > 0 then SH# = SH#-0.03 if get static collision y()<>0.0 then if SH# < 0 then SH# = SH#+0.03 endif rem Update with new object position position object 1,posx#,posy#,posz# rem camera if CWait = 0 then wait 2000 angle#=object angle y(1) camdist#=5.5 : camhigh#=posy#+0.8 : camfade#=3.5 set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1 xrotate camera 10 CWait = 1 rem collision stats if object collision(1,65531) or object collision(1,65532) or object collision(1,65533) or object collision(1,65534) then TA = 1 : goto levelstart if object collision(1,0) then position object 1,X1#,0,Z1# rem camera X1# = Object position x(1) Z1# = Object position z(1) X# = Newxvalue(X1#,aY#-180,3) Z# = Newzvalue(Z1#,aY#-180,3) Position Camera X#,3,Z# Point camera X1#,2,Z1# if Shiftkey()=1 then Position Camera X#,100,Z# : Point camera X1#,2,Z1# rem print level set cursor 550,10 print "Level ",Level rem end loop sync loop |