FPS in OGRE3D - (SOLVED) by Dark Dragon
Posted: Mon Mar 07, 2011 11:02 pm
OK I am settling two source codes here for a FPS in OGRE.
This is the first one... all graphics come from a folder called NEWIDEA which I has thoughtfully zipped up and you can find here:
http://www.bluemesapc.com/Downloads/NEWIDEA.zip
code 1:
(no attempt at physics)

This is the first one... all graphics come from a folder called NEWIDEA which I has thoughtfully zipped up and you can find here:
http://www.bluemesapc.com/Downloads/NEWIDEA.zip
code 1:
(no attempt at physics)
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Terrain
;
; modified by Ralph W Dunn / Rook ZImbabwe
; (c) 2003 - Fantaisie Software
; modified 7 MARCH 2011
; Changes applied from examples by Daniel (Dark Dragon)
;
; ------------------------------------------------------------
;
version$ = "0.09"
#CameraSpeed = 0.4
#Thing1 = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALLn = 5
#WALLs = 6
#WALLe = 7
#WALLw = 8
#DOORn = 9
#DOORs = 10
#DOORe = 11
#DOORw = 12
#RING = 13
#FLOOR = 14
Global Dim stones(10,10)
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data", #PB_3DArchive_FileSystem)
Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
LoadMesh(#FLOOR , "flor1.mesh") ; a block or cube... can be gotten from my basic MESH pack
LoadMesh(#WALLn , "WALn1.mesh")
LoadMesh(#WALLs , "WALs1.mesh")
LoadMesh(#WALLe , "WALe1.mesh")
LoadMesh(#WALLw , "WALw1.mesh")
LoadMesh(#RING, "RING0.mesh")
LoadTexture(0, "flor1.jpg") ; something to make it look nice
LoadTexture(1, "WAL2.jpg") ; something to make it look nice
LoadTexture(2, "WAL.jpg") ; something to make it look nice
CreateMaterial(#CRETE, TextureID(0))
walltex = CreateMaterial(#PB_Any, TextureID(1))
ringtex = CreateMaterial(#PB_Any, TextureID(2))
CreateEntity(#WALLn, MeshID(#WALLn), MaterialID(walltex),0,0,0)
CreateEntity(#WALLs, MeshID(#WALLs), MaterialID(walltex),0,0,0)
CreateEntity(#WALLe, MeshID(#WALLe), MaterialID(walltex),0,0,0)
CreateEntity(#WALLw, MeshID(#WALLw), MaterialID(walltex),0,0,0)
CreateEntity(#RING, MeshID(#RING), MaterialID(ringtex),0,0,0)
CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(#CRETE),0,0,0)
; throw down a floor for gravity to work on
ey = 0
ez = 0
For cx = 0 To 10
For cy = 0 To 10
Result = CopyEntity(#FLOOR, #PB_Any)
EntityLocate(Result, ey, 0, ez)
ez = ez + 10
Next
ey = ey + 10
ez = 0
Next
; north wall
For nx = 0 To 10
Result = CopyEntity(#WALLn, #PB_Any)
EntityLocate(Result, wx, 0, ez)
wx = wx + 10
Next
; south wall
wx = 0
For nx = 0 To 10
Result = CopyEntity(#WALLs, #PB_Any)
EntityLocate(Result, wx, 0, 100)
wx = wx + 10
Next
; east wall
wx = 0
For nx = 0 To 10
Result = CopyEntity(#WALLe, #PB_Any)
EntityLocate(Result, 100, 0, wx)
wx = wx + 10
Next
; west wall
wx = 0
For nx = 0 To 10
Result = CopyEntity(#WALLw, #PB_Any)
EntityLocate(Result, 0, 0, wx)
wx = wx + 10
Next
ey = 0
ez = 0
; RANDOM RINGS
For cx = 1 To 10
For cy = 1 To 10
doit = Random(5)
If doit = 1
Result = CopyEntity(#RING, #PB_Any)
EntityLocate(Result, ey, 0, ez)
EndIf
ez = ez + 10
Next
ey = ey + 10
ez = 0
Next
; hide the originals
HideEntity(#WALLn, #True)
HideEntity(#WALLs, #True)
HideEntity(#WALLe, #True)
HideEntity(#WALLw, #True)
HideEntity(#RING, #True)
; make something to see the floor with
CreateCamera(#PLAYER, 0, 0, 100, 150)
CameraLocate(#PLAYER, 10, 0, 10)
;CreateWater(#PLAYER, 0,-1,0, 190,#PB_World_WaterMediumQuality)
SkyDome("blue_sky_1.jpg",-10) ; my clouds texture...
;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity / #PB_World_DebugBody = no work
Repeat
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_A)
KeyX = -0.5
ElseIf KeyboardPushed(#PB_Key_D)
KeyX = 0.5
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_W)
KeyY = -0.5 ;#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_X)
KeyY = 0.5 ;#CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed ; dropped the /2 cause it was slowing me down
MouseY = -(MouseDeltaY()/10)*#CameraSpeed
EndIf
; to move the new node entity
RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
MoveCamera (#PLAYER, KeyX, -CameraY(#PLAYER)+4, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End