I am trying to write a program with two cameras. one viewing the 3d world from a first person point of view similar to an FPS game.
The other being a static camera that just watches the player from a fixed perspective.
The problem that I am having seems to be with the actual switching routine. If I REM the line that reads "make camera staticcam", then the camera routine for the first person camera seems to work as intended.
Is there any bright sparks out there who could suggest some code that will make the static camera routine in the program work correctly too?
Rem ***** Main Source File *****
sync on
sync rate 60
Autocam on
backdrop off
hide mouse
set window on
set display mode 1024,768,32
set window position 100,100
set ambient light 100
cls
player=1
playerspeed#=0.1
turnspeed=4
playerx#=0
playery#=-1
playerz#=-145
playercam=1
staticcam=2
groundobject=2
groundtextureimage=1
playertexture=2
make camera playercam `Make the Player Camera
make camera staticcam `Make Static Objervation Camera
MAKE OBJECT plane groundobject,1000,1000 `make a plane to serve as the ground
xrotate object groundobject,90 `rotate the plane so its angle is horizontal
load image "media\ground.jpg",groundtextureimage `load a small ground texture
texture object groundobject,groundtextureimage `texture the plane with ground texture
SCALE OBJECT TEXTURE groundobject,128,128 `make the small ground texture repeat over and over
load object "media\H-SWAT-Move.x",player `load an object to serve as a Player
load image "media\SWAT.dds",playertexture `Load the objects Texture
texture object player,playertexture `Texture the Players Object with the loaded Texture
fix object pivot player
position object player,playerx#,playery#,playerz# `Position the PLayer in Initial start position
set camera to object orientation playercam,player `make sure the Player Camera is facing same way as Player
set camera to object orientation staticcam,player `make sure the Static Camera is facing same way as Player
position camera playercam,playerx#,playery#+1.8,playerz# `position the camera in same startiing position as player
position camera staticcam,playerx#,playery#+1.8,playerz# `position the camera in same startiing position as player
set current camera playercam
DO
gosub playermove
gosub gameinfo
sync
LOOP
return
playermove:
if scancode()=17 `Check for W Key being pressed
move object player,playerspeed#`move player forward in what ever direction it faces
move camera playercam,playerspeed#`move camera forward in what ever direction it faces
endif
if scancode()=31 `Check for S Key being pressed
move object player,-playerspeed# `move player backward in what ever direction it faces
move camera playercam,-playerspeed# `move camera backward in what ever direction it faces
endif
if scancode()=30 then turn object left player,turnspeed `If D is pressed turn player left
if scancode()=32 then turn object right player,turnspeed `If A is pressed turn player right
set camera to object orientation playercam,player `Update the Camera to Players facing angle
if inkey$()="1"
set current camera staticcam
position camera staticcam,0,1,-145
endif
if inkey$()="2"
set current camera playercam
endif
return
gameinfo: ` Some Game variables printed on the screen to help the Progammer debug
set cursor 10,10
print "Scancode key being pressed = "+str$(scancode())
print "Player Z Position ";object position z(player)
print "Player y position ";object position y(player)
print "Player x position ";object position x(player)
print "Player's Y Angle:";object angle y(player)
print "screen fps "+str$(screen fps())
return
"There are no perfect ideas only perfect intentions"