Simple Game by Anonymous Coder24th Jun 2005 6:19
|
---|
Summary This is a simple game I created where you have to steer the ball into the sphere in the middle by overlapping the cone with it. When sparks shoot from the ball, you have enough poi Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem Initial settings sync on : sync rate 100 backdrop off : hide mouse start: rem setup new world gosub loading autocam on backdrop on color backdrop rgb(0,0,0) load image "textures\metal.bmp",1 rem setup matrix make matrix 1,1000,1000,10,10 randomize matrix 1,20 make object cone 1,40 zrotate object 1,180 prepare matrix texture 1,1,10,10 set matrix wireframe off 1 set matrix height 1,5,5,50 update matrix 1 make object sphere 2,60 position object 2,500,120,500 xrotate object 2,90 make object sphere 99,30 position object 99,400,120,500 load image "textures\rainbow.tga",2 load image "textures\lead.bmp",3 load image "textures\metal.bmp",4 load image "textures\fire.bmp",5 set rainbow shading on 2,2 set rainbow shading on 1,2 set rainbow shading on 99,2 hide object 99 load sound "music\music 1.ex7",1 loop sound 1 rem make particles make particles 1,5,50,20.0 position particles 1,500,0,500 set particle emissions 1,10 set particle speed 1,0.01 set particle gravity 1,-2 set particle floor 1,0 set particle emissions 1,10 set particle velocity 1,4 set particle life 1,40 hide particles 1 rem setup variables rem level 1 level#=0 x#=500 z#=500 life#=3 score#=0 difficulty#=1 rem next level next_level: level#=level#+1 x#=500 z#=500 difficulty#=level# ene#=level#*2 lifeblock#=level# requiredscore#=level#*60-1 rem requiredscore#=level# rem position camera at one height cy#=get ground height(1,cx#,cz#)+100.0 do rem make ball if object exist(3) else make object sphere 3,20 position object 3,rnd(1000),0,rnd(1000) yrotate object 3,rnd(360) position object 3,object position x(3),get ground height(1,object position x(3),object position z (3))+20,object position z(3) texture object 3,3 endif rem make and move bonus for t=100 to lifeblock#+99 if object exist(t) move object t,1.5 position object t,object position x(t),get ground height(1,object position x(t),object position z(t))+20,object position z(t) if object position x(t)>1000 then yrotate object t,object angle y(t)+120 if object position z(t)<0 then yrotate object t,object angle y(t)+120 if object position z(t)>1000 then yrotate object t,object angle y(t)+110 if object position x(t)<0 then yrotate object t,object angle y(t)+100 if object collision(t,3) then position object 3,rnd(1000),0,rnd(1000) : life#=life#+1 : score#=score#+5 else make object cube t,20 position object t,rnd(1000),0,rnd(1000) yrotate object t,rnd(360) set rainbow shading on t,4 yrotate object t,rnd(360) endif next t rem make and move enemies for t=4 to 3+ene# if object exist(t) move object t,0.1*difficulty# position object t,object position x(t),get ground height(1,object position x(t),object position z(t))+20,object position z(t) if object position x(t)>1000 then yrotate object t,object angle y(t)+120 if object position z(t)<0 then yrotate object t,object angle y(t)+120 if object position z(t)>1000 then yrotate object t,object angle y(t)+120 if object position x(t)<0 then yrotate object t,object angle y(t)+120 if object collision(t,3) then position object 3,rnd(1000),0,rnd(1000) : life#=life#-1 else make object cube t,20 position object t,rnd(1000),0,rnd(1000) yrotate object t,rnd(360) texture object t,4 endif next t rem control ball if object exist(3) move object 3,difficulty#*0.2 position object 3,object position x(3),get ground height(1,object position x(3),object position z(3))+20,object position z(3) if object collision(1,3) then yrotate object 3,object angle y(3)+0.2*difficulty# if object collision(2,3) then delete object 3 : score#=score#+20 : difficulty#=difficulty#+1 endif rem control level center text screen width()/2,10,"Level: "+str$(level#) rem control score tscore$="Score: "+str$(score#) text screen width()-200,10,tscore$ rem Control camera with arrow keys if upkey()=1 then rate#=rate#+0.1 if downkey()=1 then rate#=rate#-0.1 if leftkey()=1 then a#=wrapvalue(a#-2.0) if rightkey()=1 then a#=wrapvalue(a#+2.0) if downkey()=0 and upkey()=0 and rate#>0 then rate#=rate#-0.05 if downkey()=0 and upkey()=0 and rate#<0 then rate#=rate#+0.05 x#=newxvalue(x#,a#,rate#) z#=newzvalue(z#,a#,rate#) if rate#>5 then rate#=5 rem lose life if character goes outside of matrix or hits ball if object position x(1)>1000 then life#=life#-1 : x#=500 : z#=500 : position object 2,500,120,500 : rate#=0 if object position z(1)>1000 then life#=life#-1 : x#=500 : z#=500 : position object 2,500,120,500 : rate#=0 if object position x(1)<0 then life#=life#-1 : x#=500 : z#=500 : position object 2,500,120,500 : rate#=0 if object position z(1)<0 then life#=life#-1 : x#=500 : z#=500 : position object 2,500,120,500 : rate#=0 rem rotate ball if ball goes outside of matrix if object exist(3) if object position x(3)>1000 then yrotate object 3,object angle y(3)+120 if object position z(3)>1000 then yrotate object 3,object angle y(3)+120 if object position x(3)<0 then yrotate object 3,object angle y(3)+120 if object position z(3)<0 then yrotate object 3,object angle y(3)+120 endif rem move orbiting sphere move object 99,0.4 yrotate object 99,object angle y(99)+0.25 rem control lives lives$="Lives: "+str$(life#) text 20,10,lives$ if life#=0 then goto gameover: rem control difficulty if difficulty#<1 then difficulty=1 rem Update character y#=get ground height(1,x#,z#)+20 position object 1,x#,y#,z# yrotate object 1,a# rem Position camera to the back of the character ca#=wrapvalue(curveangle(a#,ca#,24)) cx#=newxvalue(x#,wrapvalue(ca#+180),300) cz#=newzvalue(z#,wrapvalue(ca#+180),300) position camera cx#,cy#,cz# yrotate camera wrapvalue(ca#) rem move character if object position y(2)>get ground height(1,object position x(2),object position z(2)) then xrotate object 2,90 : move object 2,0.1 yrotate object 2,object angle y(2)+0.3 xrotate object 2,object angle x(2)+0.3 rem if control key then print fps rate fps#=screen fps() if controlkey()=1 then center text screen width()/2,screen height()/2,str$(fps#) rem level control if score#>requiredscore# show particles 1 show object 99 hide object 3 if object collision (1,2) then delete object 3 : goto next_level: else hide particles 1 hide object 99 endif rem Syncronise sync rem End loop loop loading: set text font "Arial" set text size 30 sync : center text screen width()/2,screen height()/2,"LOADING" : sync return gameover: open to write 1,"927.x13" write string 1,str$(score#) close file 1 g#=0 position camera 500,50,500 while spacekey()=0 center text screen width()/2,screen height()/2,"GAME OVER" center text screen width()/2,screen height()/2+30,"Score:" center text screen width()/2,screen height()/2+60,str$(score#) center text screen width()/2,screen height()/2+90,"Press Space to Restart" color backdrop rgb(200-g#/3,200-g#/4,200-g#/2) g#=g#+0.5 yrotate camera camera angle y()+0.1 move camera 0.2 position camera camera position x(),get ground height(1,camera position x(),camera position z())+20,camera position z() sync endwhile for t=1 to ene#+3 delete object t next t delete sound 1 for t=1 to 4 delete image t next t delete matrix 1 delete particles 1 delete object 99 sync goto start: |