Rightyho. Here's the code. Now let's see if I can remember how to do that funky "green-on-black" thing when people post code:
;------------------------------------------------------------
;NOTE: These variables are put here only for the purpose of faster testing. Once finished, get rid of 'em!
Const FPS=60
Const width=800,height=600,depth=0
Global mode=0
Global a=255
Global lightenvcolour=0
;------------------------------------------------------------
;------------------------------------------------------------
;Starter pointers - keep these in to be able to run the application.
Graphics3D width,height,depth,mode
SetBuffer BackBuffer()
SeedRnd = MilliSecs()
Function Update_Player_Cam()
;-------------------------------
; + and - to change sensitivity
If KeyDown(13) Then cam_sens=cam_sens-1
If KeyDown(12) Then cam_sens=cam_sens+1
If cam_sens<=0 Then cam_sens=1
;
;-------------------------------
; Zooming function
If MouseDown(1)
zoom=(MouseYSpeed()-zoom)/13+zoom
mouseXs=(0-mouseXs)/cam_sens+mouseXs
mouseYs=(0-mouseYs)/cam_sens+mouseYs
Else
zoom=(0-zoom)/13+zoom
mouseXs=(MouseXSpeed()-mouseXs)/cam_sens+mouseXs
mouseYs=(MouseYSpeed()-mouseYs)/cam_sens+mouseYs
EndIf
MoveEntity chaseCam,mouseXs,mouseYs,zoom
PointEntity chaseCam,chaseCamPivot
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
End Function
Function CreatePlayer.Player(posx,posy,posz,rotx,roty,rotz,player_no)
p.Player = New Player
p\entity = CreatePivot()
p\player_no = player_no
p\model = LoadMD2("Models/player"+player_no+"/player"+player_no+".md2")
p\texture = LoadTexture("Models/player"+player_no+"/player"+player_no+"text.bmp")
EntityTexture p\model,p\texture
FreeTexture p\texture
AnimateMD2 p\model,1,0.7,1,40
ScaleEntity p\model,.08,.08,.08
p\player_x = posx
p\player_y = posy
p\player_z = posz
MoveEntity p\model,p\player_x,p\player_y,p\player_z
RotateEntity p\model,rotx,roty,rotz
End Function
Type Player
Field entity,model,texture
Field player_x#,player_y#,player_z#,player_no,stats
End Type
;------------------------------------------------------------
Global playerCam,CameraPivot,mouseXs#,mouseYs#,zoom#,cam_sens
;------------------------------------------------------------
;The juicy bits
SetBuffer BackBuffer ()
p.Player=CreatePlayer(0,5,0,0,180,0,1)
Global chaseCam=CreateCamera()
Global chaseCamPivot=CreatePivot()
CameraViewport chaseCam,0,0,GraphicsWidth(),GraphicsHeight()
PositionEntity chaseCam,0,20,30
PositionEntity chaseCamPivot,0,8,0
cam_sens=5
EntityRadius chaseCam,4
EntityType chaseCam,1
Repeat
Update_Player_Cam()
;----------------------------------
UpdateWorld
RenderWorld tween
Text 0,0,"Press the '+' and '-' keys to set the camera's sensitivity."
Text 0,10,"Camera sensitivity="+cam_sens
Text 0,20,"CameraX="+EntityX(chaseCam)
Text 0,30,"CameraY="+EntityY(chaseCam)
Text 0,40,"CameraZ="+EntityZ(chaseCam)
Text 0,50,"Press the X button to destroy the player and replace with a different character."
Flip
Until KeyDown(1)
End
This is actually tested on two computers, with the same results, so it must be the coding. What could be the problem?
;------------------------------------------------------------
;NOTE: These variables are put here only for the purpose of faster testing. Once finished, get rid of 'em!
Const FPS=60
Const width=800,height=600,depth=0
Global mode=0
Global a=255
Global lightenvcolour=0
;------------------------------------------------------------
;------------------------------------------------------------
;Starter pointers - keep these in to be able to run the application.
Graphics3D width,height,depth,mode
SetBuffer BackBuffer()
SeedRnd = MilliSecs()
Function Update_Player_Cam()
;-------------------------------
; + and - to change sensitivity
If KeyDown(13) Then cam_sens=cam_sens-1
If KeyDown(12) Then cam_sens=cam_sens+1
If cam_sens<=0 Then cam_sens=1
;
;-------------------------------
; Zooming function
If MouseDown(1)
zoom=(MouseYSpeed()-zoom)/13+zoom
mouseXs=(0-mouseXs)/cam_sens+mouseXs
mouseYs=(0-mouseYs)/cam_sens+mouseYs
Else
zoom=(0-zoom)/13+zoom
mouseXs=(MouseXSpeed()-mouseXs)/cam_sens+mouseXs
mouseYs=(MouseYSpeed()-mouseYs)/cam_sens+mouseYs
EndIf
MoveEntity chaseCam,mouseXs,mouseYs,zoom
PointEntity chaseCam,chaseCamPivot
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
End Function
Function CreatePlayer.Player(posx,posy,posz,rotx,roty,rotz,player_no)
p.Player = New Player
p\entity = CreatePivot()
p\player_no = player_no
p\model = LoadMD2("Models/player"+player_no+"/player"+player_no+".md2")
p\texture = LoadTexture("Models/player"+player_no+"/player"+player_no+"text.bmp")
EntityTexture p\model,p\texture
FreeTexture p\texture
AnimateMD2 p\model,1,0.7,1,40
ScaleEntity p\model,.08,.08,.08
p\player_x = posx
p\player_y = posy
p\player_z = posz
MoveEntity p\model,p\player_x,p\player_y,p\player_z
RotateEntity p\model,rotx,roty,rotz
End Function
Type Player
Field entity,model,texture
Field player_x#,player_y#,player_z#,player_no,stats
End Type
;------------------------------------------------------------
Global playerCam,CameraPivot,mouseXs#,mouseYs#,zoom#,cam_sens
;------------------------------------------------------------
;The juicy bits
SetBuffer BackBuffer ()
p.Player=CreatePlayer(0,5,0,0,180,0,1)
Global chaseCam=CreateCamera()
Global chaseCamPivot=CreatePivot()
CameraViewport chaseCam,0,0,GraphicsWidth(),GraphicsHeight()
PositionEntity chaseCam,0,20,30
PositionEntity chaseCamPivot,0,8,0
cam_sens=5
EntityRadius chaseCam,4
EntityType chaseCam,1
Repeat
Update_Player_Cam()
;----------------------------------
UpdateWorld
RenderWorld tween
Text 0,0,"Press the '+' and '-' keys to set the camera's sensitivity."
Text 0,10,"Camera sensitivity="+cam_sens
Text 0,20,"CameraX="+EntityX(chaseCam)
Text 0,30,"CameraY="+EntityY(chaseCam)
Text 0,40,"CameraZ="+EntityZ(chaseCam)
Text 0,50,"Press the X button to destroy the player and replace with a different character."
Flip
Until KeyDown(1)
End
This is actually tested on two computers, with the same results, so it must be the coding. What could be the problem?