Heres the code (more below the code):
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - SkyDome
;
; (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 25
IncludeFile "Screen3DRequester.pb"
DefType.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
AmbientColor(RGB(255,255,255))
CreateMaterial(0, LoadTexture(2, "r2skin.jpg"))
CreateEntity (0, LoadMesh(2, "Robot.mesh"), MaterialID(0), -1, -2, -3)
CreateMaterial (0, LoadTexture(0, "Terrain_Texture.jpg"))
AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1)
CreateTerrain("Terrain.png", MaterialID(0), 40, 1, 40, 0)
SkyDome("Clouds.jpg", 30)
CreateCamera(0,0,0,100,100)
CameraLocate(0,3700,20,1775)
Repeat
Screen3DEvents()
Ground = TerrainHeight(oldx,oldz)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = CameraX(0) - #CameraSpeed ;- I changed all of these to say CameraX(0)
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = CameraX(0) + #CameraSpeed
Else
KeyX = CameraX(0)
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = CameraZ(0) - #CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = CameraZ(0) + #CameraSpeed
Else
KeyY = CameraZ(0)
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
oldx = CameraX(0)
oldy = ground + 20
oldz = CameraZ(0)
;- This is where I changed it to attempt a gravity effect -------------------
CameraLocate(0, KeyX, oldy, KeyY)
RotateCamera(0, MouseX, MouseY, RollZ)
;MoveCamera (0, KeyX, 0, KeyY)
; Get Terrain Height -----------------------------------------------------------
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
What happens here is:
1. The camera stays at 20 above the terrain height.
2. The camera can look around.
3. When you move, using the up arrow key, it only goes 1 direction.
same with all the other keys. The movement does not match what
way the camera is looking.
If anyone could throw some hints as to what I can do to get this working, it would be much appreciated.
Is there a function for determining where the camera is pointing? If so, how could I get the movement to change to that direction?
thanks