rem
rem First Person Game TUTORIAL
rem
rem How to create an FPS Creator Level for loading into DBPro:
rem 1. Run FPSCREATOR.EXE and scroll to the TOP/LEFT/BOTTOM corner of the editing area
rem 2. Use PREFAB to make a room in this corner
rem 3. Click the BUILD GAME button to build the level as an executable
rem 4. Exit FPSCREATOR.EXE and navigate to MyGames\yourexe\
rem 5. Copy the FILES folder to this source code folder
rem 6. Delete all folders within FILES folder except 'levelbank' and 'texturebank'
rem 7. Navigate to FILES\LEVELBANK and unzip the level1.zip using 'mypassword'
rem 8. Create a new folder called TESTLEVEL
rem 9. Copy the files you have extracted to this folder, then navigate to the files
rem 10. Delete all except UNIVERSE.DBO, UNIVERSE.DBU and the LIGHTMAPS folder
rem 11. Ensure the 'Files' folder sits alongside this application and run
collision=2 : arbitaryvalue=0 : shadow=1 : portal=1 : o=1
rem Use desktop resolution, vsync on
sync on : sync rate 0
desktopwidth=desktop width()
desktopheight=desktop height()
set display mode desktopwidth,desktopheight,32,1
rem Initialise application and hide mouse pointer
autocam off : hide mouse
backdrop on
rem Set font
set text font "Copperplate Gothic Bold"
ink rgb(255,255,200),0
set text size 24
rem Load or Create static universe
tfile$="universe.dbo"
if file exist(tfile$)=1
`
rem load from previously created file
dividetexturesize=0 : load static objects tfile$,dividetexturesize
`
rem Can use objects from OMAX onwards
omax=1
`
else
rem Load level (load static objects read a DBO and DBU file pair)
universefile$="testmap\Test.x"
load object universefile$,o,1,1
rem make object box o,5000,10,5000
position object o,0,-100,0
make static object o,collision,arbitaryvalue,shadow,portal :
inc o
load object universefile$,o,1,1
rem make object box o,5000,10,5000
position object o,0,100,0
make static object o,collision,arbitaryvalue,shadow,portal :
rem make mesh from object 1,o : position object o,0,-10,0
rem for l=1 to 1 : add limb o,l,1 : offset limb o,l,0,0,0 : make static limb o,l,collision,arbitaryvalue,shadow,portal : next l : inc o
rem Place camera (the topmost/leftmost/lowest tile of the FPSC level universe)
rem Remember that these coordinates will change with each new FPSC level used
position camera 100,30,-100
point camera 100,20,-100
rem set ambient light 100
build static portals : delete light map lights : add static objects to light map pool
add limb to light map pool 1,1 : inc o
add light map light 400,90,800,500,255,0,0,50,1
add light map light 200,90,400,500,0,255,0,50,1
add light map light 800,90,200,500,0,0,255,50,1
set static scorch scorchimage,1,1
set ambient light 20
endif
set normalization on :
rem Main
texturesize=16 : texturequality=1 : lightmapsavepath$="lightmaps"
if path exist(lightmapsavepath$)=0 then make directory lightmapsavepath$
create light maps texturesize,texturequality,lightmapsavepath$
if file exist(tfile$)=1 then delete file tfile$
save static objects tfile$
do
rem cls 0
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
`
cx#=camera position x() : cz#=camera position z()
Rem Control input for camera
`move forwards
If keystate(17)=1
cX# = Newxvalue(cX#,CameraAngleY#,10)
cZ# = Newzvalue(cZ#,CameraAngleY#,10)
Endif
`move backwards
If keystate(31)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#-180),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#-180),10)
Endif
`move left
If keystate(30)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#-90),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#-90),10)
Endif
`move right
If keystate(32)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#+90),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#+90),10)
Endif
`mouse movement
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
position camera cx#,100,cz# `this is the main part of the code, use
`normal wsad controls with the x and z positions but intersect the terrain object with the y position
camx = camera position x (0)
camy = camera position y (0)
camz = camera position z (0)
cx#=camera position x() : cz#=camera position z()
sync
rem Debug
if keystate(41)=1
set cursor 0,0 : print "FPS: ";screen fps():print "X Position : " ,camx:print "Y Position : " , camy:print "Z Position : " , camz
endif
`
rem Update screen
sync
`
rem End loop
loop
don't save!!!