Basics for FPS (first person shooter) by Vusay3rd Mar 2004 3:02
|
---|
Summary This gives you the main things you will need to start off your fps. Description This gives you the main things you will need to start off your fps. It has fps styled commands and the main code was pieced together using many different codes. It is ideal for games in the night because of the look of the fog. A small simple matrix for you to use, but overall a great idea. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com autocam off hide mouse `make objects and matrix make object sphere 4,50 position object 4,0,100,0 make matrix 1,4000,4000,30,30 Fog on Fog distance 2000 Fog color RGB(0,0,5) Color Backdrop RGB(0,0,5) Make object cylinder 1,2 xrotate object 1,90 fix object pivot 1 scale object 1,100,100,500 position object 1,0,-7,15 lock object on 1 make object sphere 2,3 hide object 2 hide object 4 `set camera and sync set camera range 1,3000 sync on sync rate 100 `begin game loop do `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 if controlkey()=1 and ajump=1 jumpb=1 height=30 endif if jumpb=1 height=height-1 position object 4,object position x(4),object position y(4)+height,object position z(4) endif if object position y(4)>100 then ajump=0 else ajump=1 if object position y(4)<100 position object 4,object position x(4),100,object position z(4) jump=0 height=0 endif `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,100 dst=dst+1 endif `sync sync `end game loop loop |