I first "Load Static Objects" which is an imported FPSC DBO map file. I then position the camera within this "Universe" or "Level" where I want the player to start. I am also using mouselook for an FP perspective.
Here is the code which all works fine.
backdrop on : hide mouse
sync on : sync rate 200
disable escapekey
autocam off
rotate camera 0,0,0
`variables
debug=1
PlayerWalk# = 1
PlayerWalkFast# = 2
PlayerRun# = 3
rem texturesize is used to load lower resolution textures.
texturesize=0
`set dir
set dir "files"
`Load level (load static objects read a DBO and DBU file pair)
load static objects "levelbank\testlevel\universe.dbo",0
`this is object that is at camera position. it is a dummy object
`hopefully to emulate camera collision
`pos is always that of the camera
make object box 100,30,30,30
rem Place camera (the topmost/leftmost/lowest tile of the FPSC level universe)
set ambient light 35
CurrentCoordinateX#=50
CurrentCoordinateY#=70
CurrentCoordinateZ#=-275
collision = 0
minDistance = 20
rem Main loop
repeat
rem intersect
rem set the variables to be used for raycasting
ox#=object position x(100)
oy#=object position y(100)
oz#=object position z(100)
oay#=object angle y(100)
newX# = newxvalue(ox#, oay#, 1000)
newZ# = newzvalue(oz#,oay#,1000)
leftX# = newxvalue(ox#, oay# - 90, 1000)
leftZ# = newzvalue(oz#,oay# - 90,1000)
rightX# = newxvalue(ox#, oay# + 90, 1000)
rightZ# = newzvalue(oz#,oay# + 90,1000)
backX# = newxvalue(ox#, oay# + 180, 1000)
backZ# = newzvalue(oz#,oay# + 180,1000)
rem Perform the raycasting to look for walls
Distance2Front# = static raycast(ox#, oy#, oz#,newX# , oy#, newZ#)
Distance2Left# = static raycast(ox#, oy#, oz#,leftX# , oy#, leftZ#)
Distance2Right# = static raycast(ox#, oy#, oz#,rightX# , oy#, rightZ#)
Distance2Back# = static raycast(ox#, oy#, oz#,backX# , oy#, backZ#)
`the following code emulates mouselook for fp perspective
`code for mouselook
OCAY# = CurrentCameraAngleY#
OCAX# = CurrentCameraAngleX#
CurrentCameraAngleY# = WrapValue(CurrentCameraAngleY#+MousemoveX()*0.2)
CurrentCameraAngleX# = WrapValue(CurrentCameraAngleX#+MousemoveY()*0.2)
Rem Control input for camera
If Upkey()=1
TestAngleX# = Newxvalue(CurrentCoordinateX#,CurrentCameraAngleY#,PlayerWalk#)
TestAngleZ# = Newzvalue(CurrentCoordinateZ#,CurrentCameraAngleY#,PlayerWalk#)
if Distance2Front# > minDistance
CurrentCoordinateX#=TestAngleX#
CurrentCoordinateZ#=TestAngleZ#
endif
Endif
If Downkey()=1
TestAngleX# = Newxvalue(CurrentCoordinateX#,Wrapvalue(CurrentCameraAngleY#-180),PlayerWalk#)
TestAngleZ# = Newzvalue(CurrentCoordinateZ#,Wrapvalue(CurrentCameraAngleY#-180),PlayerWalk#)
if Distance2Back# > minDistance
CurrentCoordinateX#=TestAngleX#
CurrentCoordinateZ#=TestAngleZ#
endif
Endif
If Leftkey()=1
TestAngleX# = Newxvalue(CurrentCoordinateX#,Wrapvalue(CurrentCameraAngleY#-90),PlayerWalk#)
TestAngleZ# = Newzvalue(CurrentCoordinateZ#,Wrapvalue(CurrentCameraAngleY#-90),PlayerWalk#)
if Distance2Left# > minDistance
CurrentCoordinateX#=TestAngleX#
CurrentCoordinateZ#=TestAngleZ#
endif
Endif
If Rightkey()=1
TestAngleX# = Newxvalue(CurrentCoordinateX#,Wrapvalue(CurrentCameraAngleY#+90),PlayerWalk#)
TestAngleZ# = Newzvalue(CurrentCoordinateZ#,Wrapvalue(CurrentCameraAngleY#+90),PlayerWalk#)
if Distance2Right# > minDistance
CurrentCoordinateX#=TestAngleX#
CurrentCoordinateZ#=TestAngleZ#
endif
Endif
yrotate object 100,CurveAngle(CurrentCameraAngleY#,OCAY#,24)
xrotate object 100,CurveAngle(CurrentCameraAngleX#,OCAX#,24)
Yrotate camera CurveAngle(CurrentCameraAngleY#,OCAY#,24)
Xrotate camera CurveAngle(CurrentCameraAngleX#,OCAX#,24)
`end mouselook code
`now position object and camera
position object 100, CurrentCoordinateX#,CurrentCoordinateY#,CurrentCoordinateZ#
position Camera CurrentCoordinateX#,CurrentCoordinateY#,CurrentCoordinateZ#
if debug = 1
text 5,5, str$(screen fps())
text 5,45, "front " + str$(Distance2Front#)
text 5,65, " left " + str$(Distance2Left#)
text 5,85, " right " + str$(Distance2Right#)
text 5,105, " back " + str$(Distance2Back#)
endif
rem Update
sync
until escapekey()=1
rem Close level
delete static objects
end
When I begin the player is facing the wall. I would like the player (camera) to be looking in the opposite direction (away from the wall). How do I accomplish this seemingly simple correction? I have tried 14 different camera commands starting with "Point Camera" and then the "Rotate Camera" and the individual "X,Y,ZRotate Camera" None seems to work. At least the variations I have tried have not worked. I either am doing something wrong, or, it can't be done (I've ruled that out only because of the FPSC player marker), or I have not found the correct command or commands to do this.
As opposed to Highlander.