First Person Shooter (random matrix ground and special light effects) by Francesco11th Apr 2004 6:00
|
---|
Summary Little game I created out of a code I downloaded from this site. Description You have to go around a matrix territory find the yellow ball and shoot at it. Your score will go down (even though the score part doesn't work very well) when you don't hit the ball and up when you hit it. If you hit the ball this will automaticly repositionate in another part of the territory, for you to find it again. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com autocam off hide mouse rem Make a floor texture cls rgb(0,255,0) get image 1,0,0,32,32 `make objects and matrix make object box 4,2,2,15 position object 4,0,-5,-250 make matrix 1,4000,4000,30,30 randomize matrix 1,5.0 prepare matrix texture 1,1,1,1 rem Create rough ground by altering normals for x=0 to 25 for z=0 to 25 set matrix normal 1,x,z,0,0.9-(rnd(5)/10.0),0 next z next x d#=0 make object sphere 5,50 color object 5,-255 position object 5,rnd(4000),get ground height(1,object position x(5)+25,object position z(5))+50,rnd(4000) Fog on Fog distance 2000 Fog color RGB(0,0,5) Color Backdrop RGB(0,0,5) set matrix wireframe off 1 set normalization on Make object cylinder 1,2 xrotate object 1,90 fix object pivot 1 scale object 1,100,100,500 position object 1,0,object position y(4),15 lock object on 1 make object sphere 2,3 color object 2,0 hide object 2 hide object 4 set ambient light 0 set point light 0,0,0,0 position light 0,2000,300,2000 make light 1 set spot light 1,30,50 position light 1,object position x(4),object position y(4)-20,object position z(4) `set camera and sync set camera range 1,3000 sync on sync rate 1000 `begin game loop do position light 1,object position x(4),object position y(4),object position z(4) point light 1,object position x(5),object position y(5),object position z(5) set light range 1,10000 color light 1,-255 `position camera at location and rotation of object 4 position camera object position x(4),object position y(4),object position z(4) rotate camera object angle x(4),object angle y(4),object angle z(4) `define camera variables wvtx=object angle x(4) wvty=object angle y(4) wvtz=object angle z(4) wcax=wrapvalue(wvtx) wcay=wrapvalue(wvty) wcaz=wrapvalue(wvtz) `controls `aiming cya#=wrapvalue(cya#+(mousemovex()/3.0)) cxa#=cxa#+(mousemovey()/3.0) if cxa#<-45.0 then cxa#=-45.0 if cxa#>45.0 then cxa#=45.0 cx#=newxvalue(x#,cya#,sin(cxa#)*10) cz#=newzvalue(z#,cya#,sin(cxa#)*10) rotate camera wrapvalue(cxa#),cya#,0 rotate object 4,0,camera angle y(),0 position camera object position x(4),object position y(4),object position z(4) `walking If keystate(17)=1 then move object 4,8 If keystate(31)=1 then move object 4,-8 `jumping position object 4,object position x(4),get ground height(1,object position x(4),object position z(4))+80,object position z(4) if controlkey()=1 and ajump=1 jumpb=1 height=300 endif if jumpb=1 height=height-2.5 position object 4,object position x(4),object position y(4)+height,object position z(4) endif if object position y(4)>250 then ajump=0 else ajump=1 if object position y(4)<150 position object 4,object position x(4),object position y(4)+height,object position z(4) jump=0 height=0 endif if object collision(5,2)=1 then position object 5,rnd(4000),get ground height(1,object position x(5),object position z(5))+25,rnd(4000) `shooting if mouseclick()>0 and dst=0 shot=1 bdst=1 show object 2 position object 2,object position x(4),object position y(4)-1,object position z(4) rotate object 2,camera angle x(),camera angle y(),camera angle z() endif if object position x(2)<0 or object position x(2)>4000 or object position z(2)>4000 or object position z(2)<0 or object position y(2)<0 or object position y(2)>1000 hide object 2 dst=0 shot=0 endif if shot=1 dst=dst+1 bdst=bdst+1 endif if shot=1 move object 2,50 dst=dst+1 endif if inkey$="m" then position object 5,rnd(4000),get ground height(1,object position x(5)+25,object position z(5))+20,rnd(4000) r#=timer() if object collision(5,2)=1 then d#=d#+4 if object visible(2) and 1=(timer()-r#) then d#=d#-1 set cursor 50,50 print "SCORE ",d# sync `sync `end game loop loop |