TGC Codebase Backup



FPS Controls by Iain

25th Jan 2008 16:06
Summary

A simple program showing some basic FPS controls.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem First Person Shooter Engine V1.0 By Iain McCluskey

sync on
sync rate 30
hide mouse

make matrix 1,2500,2500,25,25
randomize matrix 1,30
update matrix 1

do

rotate camera camera angle x(0)+(mousemovey()/2.5),camera angle y(0)+(mousemovex()/2.5),0

ax# = camera angle x()
ay# = camera angle y()

if upkey() = 1
  xrotate camera 0
  move camera 5
  xrotate camera ax#
endif
if downkey() = 1
  xrotate camera 0
  move camera - 5
  xrotate camera ax#
endif
if leftkey() = 1
  yrotate camera ay# - 90
  move camera 5
  yrotate camera ay#
endif
if rightkey() = 1
  yrotate camera ay# + 90
  move camera 5
  yrotate camera ay#
endif

x# = camera position x()
y# = get ground height(1,x#,z#) + 100
z# = camera position z()

position camera x#,y#,z#

sync

loop