Isometric camera by Skywriter29th Sep 2010 14:58
|
---|
Summary Isometric camera example. Navigate,rotate with cursor keys + mouse. Moves 4 directions, sustaining rotation on angle x or y axis.Can be implemented to use with mouse(rotation). Sim Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com sync on sync rate 60 make matrix 1,100,100,10,10 position camera 0, 0,10,0 rotate camera 0,1,0 global camheight=10 do xpos = camera position x(0) zpos = camera position z(0) camRotY = wrapvalue(camera angle y(0)) camRotX = wrapvalue(camera angle x(0)) Isometric_Camera(xpos,zpos,camRotY,camRotX) text 0,10,"FPS = "+str$(screen fps()) sync loop function Isometric_Camera(xpos,zpos,rot_angy,rot_angx) camspeed# = 2.0 var=mousemovez() select var case 120 inc camheight,1 endcase case -120 dec camheight,1 endcase endselect if mouseclick()=0 if upkey()=1 inc xpos, sin(rot_angy)*camspeed# inc zpos, cos(rot_angy)*camspeed# endif if downkey()=1 dec xpos, sin(rot_angy)*camspeed# dec zpos, cos(rot_angy)*camspeed# endif if leftkey()=1 left_ang=rot_ang+90 dec xpos, sin(left_angy)*camspeed# dec zpos, cos(left_angy)*camspeed# endif if rightkey()=1 right_ang=rot_angy-90 dec xpos, sin(right_ang)*camspeed# dec zpos, cos(right_ang)*camspeed# endif else if mouseclick()=1 and leftkey()=1 dec rot_angy,1 endif if mouseclick()=1 and rightkey()=1 inc rot_angy,1 endif if mouseclick()=2 and upkey()=1 dec rot_angx,1 endif if mouseclick()=2 and downkey()=1 inc rot_angx,1 endif endif position camera 0,xpos,camheight,zpos rotate camera rot_angx,rot_angy,0 endfunction |