Page 1 of 1

OGRE FPS Code - 26 MAR 2011 - Now with Compass!

Posted: Mon Mar 14, 2011 9:50 pm
by Rook Zimbabwe
OK this is what I have so far with the help of Daniel (Dark Dragon) and a number of others.

I do not think that OGRE is culling unseen TRIs... Each #WALL on screen is 8 TRI... the #FLOOR is 2 TRI and the #DOOR (the most complex) is 60ish... in no way should that overload the most basic graphics card!

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)
; ****** THIS IS MY ATTEMPT AT SOLID MESH
;
; ------------------------------------------------------------
;

version$ = "0.09"


#FLOOR = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALL = 5
#DOOR = 6

#CameraSpeed = 16

; create an array to hold the junk
; * KNOW this works as the program does not DIE when added

Global mazewidth = 20
Global mazeheight = 20
Global Dim maze(mazewidth,mazeheight)
; fill array with nothings
For x = 0 To mazewidth
  For y = 0 To mazeheight
    maze(x,y) = 0
  Next
Next

Procedure ScreenWidth()
  !extrn _PB_Screen_RealWidth
  !mov eax, dword [_PB_Screen_RealWidth]
  ProcedureReturn
EndProcedure

Procedure ScreenHeight()
  !extrn _PB_Screen_RealHeight
  !mov eax, dword [_PB_Screen_RealHeight]
  ProcedureReturn
EndProcedure

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  EnableWorldPhysics(#True)
  EnableWorldCollisions(#True)
  
  WorldGravity(51.1)  ;EARTH // (91.1) ; MARSish
  
  If Screen3DRequester()
    ;- LOAD ENTITY
    
    LoadMesh(#FLOOR , "flor1.mesh") ; a block or cube... can be gotten from my basic MESH pack
    LoadMesh(#WALL , "CUBE1.mesh")
    
    LoadMesh(#DOOR, "DOOR1.mesh")
    LoadMesh(#DUDE, "GUY1.mesh") ; ****** our player for the node
    
    LoadTexture(0, "RUST1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL1.jpg") ; something to make it look nice
    LoadTexture(2, "flor2.jpg") ; something to make it look nice
    
    walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
    DOORtex = CreateMaterial(#PB_Any, TextureID(0))
    floortex = CreateMaterial(#PB_Any, TextureID(2))
    
    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(floortex),0,0,0)
    CreateEntity(#WALL, MeshID(#WALL), MaterialID(walltex),0,0,0)
    CreateEntity(#DOOR, MeshID(#DOOR), MaterialID(DOORtex),0,0,0)
    
    CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),100,4,100)
    EntityPhysicBody(#DUDE ,#PB_Entity_BoxBody , #PB_Entity_AbsoluteBodyMove)
    SetEntityMass(#DUDE, 1.0)
    
    
    ;- CREATE CAMERA
    
    CreateCamera(#PLAYER, 0, 0, 100, 100)
    
    ; Fog(RGB(0,0,0), 1, 0, 30)
    
    ;- MAKE FLOOR 20 X 20
    ey = 0
    ez = 0
    For cx = 0 To 20
      For cy = 0 To 20
        Result = CopyEntity(#FLOOR, #PB_Any)
        EntityLocate(Result, ey, 0, ez)
        EntityPhysicBody(Result, #PB_Entity_StaticBody)
        SetEntityMass(Result, 10.0)
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ; north wall
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; south wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, 200)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; east wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 200, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; west wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ey = 0
    ez = 0
    ; now For a small test...
    times = Random(80) + 30 ; random number of objects between 30 and 80
    
    For whop = 0 To times
      x = Random(20)
      y = Random(20)
      maze(x,y) = Random(1)+2 ; random between 2 and 3 for now to place walls and doors
      Debug "SET = "+Str(times)
    Next
    ; * program still working
    
    ; *** read array to set the random walls and doors
    blocksize = 10
    Debug "=-=-=-=-=-=-   READING ARRAY!"
    For y=1 To mazeHeight-1
      For x=1 To mazeWidth-1
        If maze(x,y) = 2
          Result = CopyEntity(#DOOR, #PB_Any)
          EntityLocate(Result, x*blockSize, 0, y*blockSize)
          EntityPhysicBody(Result ,#PB_Entity_StaticBody)
          SetEntityMass(Result, 10.0)
          Debug "******  DOOR SET!"
        ElseIf maze(x,y) = 3
          Result = CopyEntity(#WALL, #PB_Any)
          EntityLocate(Result, x*blockSize, 0, y*blockSize)
          EntityPhysicBody(Result ,#PB_Entity_StaticBody)
          SetEntityMass(Result, 10.0)
          Debug "****** WALL SET!"
        EndIf
      Next
    Next
    Debug "<><><><><>< ARRAY READ"
    ; make sure there is a clear space for us to start on
    Result = CopyEntity(#FLOOR, #PB_Any)
    EntityPhysicBody(Result ,#PB_Entity_StaticBody)
    SetEntityMass(Result, 10.0)
    ;- hide the originals
    HideEntity(#WALL, #True)
    HideEntity(#DOOR, #True)
    HideEntity(#DUDE, #True)
    
    
    ; *** uncomment to see bounding boxes
    ;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    
    EnableWorldCollisions(1)
    EnableWorldPhysics(1)
    
    EntityLocate(#DUDE, 100,0,100)
    
    ;- START OF LOOP
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
      EndIf
      
      If ExamineMouse()
        MouseX - MouseDeltaX() / 2
        MouseY - MouseDeltaY() / 2
      EndIf
      
      PointPick(#PLAYER, ScreenWidth() / 2, ScreenHeight() / 2)
      
      RotateCamera(#PLAYER, MouseY, MouseX, 0, #PB_Absolute)
      RotateEntity(#DUDE, 0, MouseX, 0, #PB_Absolute)
      MoveEntity(#DUDE, -KeyY * PickX() - KeyX * PickZ(), 0, -KeyY * PickZ() + KeyX * PickX())
      CameraLocate(#PLAYER, EntityX(#DUDE), EntityY(#DUDE)+4, EntityZ(#DUDE))
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

meshes and textures can be grabbed from:
http://www.bluemesapc.com/Downloads/FPS01.zip

Any help would be nice! :mrgreen:

{{EDIT}}
OK I have just changed line 89 to:

Code: Select all

CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),100,4,100)
    EntityPhysicBody(#DUDE ,#PB_Entity_SphereBody , #PB_Entity_AbsoluteBodyMove)
    SetEntityMass(#DUDE, 1.0)
and it WORKS and is smooth... whats going on!!!
{{ / EDIT }}

OK now someone can attempt Joakims MAZE as I have other ideas!

Re: OGRE First Person Code - Thoughts 14 MARCH 2011

Posted: Mon Mar 14, 2011 10:08 pm
by Rook Zimbabwe
Somehow you can still fall through the floor and you seem to jump UP afterlooking down... fall through floor when looking down and moving... may have to limit chin movement somehow... :mrgreen:

Re: OGRE First Person Code - Thoughts 14 MARCH 2011

Posted: Tue Mar 15, 2011 7:19 am
by Nituvious
I never could get this to work, The specified #Texture is not initialized. :oops:

Re: OGRE First Person Code - Thoughts 14 MARCH 2011

Posted: Tue Mar 15, 2011 4:06 pm
by Rook Zimbabwe
If you make a folder in whatever directory you saved the code in called NEWIDEA and put all models and meshes in that folder... it will run just fine... new code with a single plan and spacebar jump (emergency no fall through) action

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)
; ****** THIS IS MY ATTEMPT AT SOLID MESH
;
; ------------------------------------------------------------
;

version$ = "0.09"


#FLOOR = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALL = 5
#DOOR = 6

#CameraSpeed = 16

; create an array to hold the junk
; * KNOW this works as the program does not DIE when added

Global mazewidth = 20
Global mazeheight = 20
Global Dim maze(mazewidth,mazeheight)
; fill array with nothings
For x = 0 To mazewidth
  For y = 0 To mazeheight
    maze(x,y) = 0
  Next
Next

Procedure ScreenWidth()
  !extrn _PB_Screen_RealWidth
  !mov eax, dword [_PB_Screen_RealWidth]
  ProcedureReturn
EndProcedure

Procedure ScreenHeight()
  !extrn _PB_Screen_RealHeight
  !mov eax, dword [_PB_Screen_RealHeight]
  ProcedureReturn
EndProcedure

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
     Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
     Add3DArchive(#PB_Compiler_Home + "Examples\Sources\Data", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  EnableWorldPhysics(#True)
  EnableWorldCollisions(#True)
    
  If Screen3DRequester()
    ;- LOAD ENTITY
    
    LoadMesh(#FLOOR , "FLOR1.mesh")
    
    LoadMesh(#WALL , "CUBE1.mesh")
    LoadMesh(#DOOR, "DOOR1.mesh")
    LoadMesh(#DUDE, "GUY1.mesh") ; ****** our player for the node
    
    LoadTexture(0, "RUST1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL1.jpg") ; something to make it look nice
    LoadTexture(2, "terrain_texture.jpg") ; something to make it look nice
    
    walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
    DOORtex = CreateMaterial(#PB_Any, TextureID(0))
    floortex = CreateMaterial(#PB_Any, TextureID(2))
    ;CreateMaterial(#PB_Any, LoadTexture(1, "terrain_texture.jpg"))

    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(floortex))
    ScaleEntity(#FLOOR, 30, 0, 30)
    EntityLocate(#FLOOR, 100, -1, 100)
    EntityPhysicBody(#FLOOR ,#PB_Entity_StaticBody)
    SetEntityMass(#FLOOR, 10.0)
    
    CreateEntity(#WALL, MeshID(#WALL), MaterialID(walltex),0,0,0)
    CreateEntity(#DOOR, MeshID(#DOOR), MaterialID(DOORtex),0,0,0)
    
    CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),100,4,100)
    ;EntityPhysicBody(#DUDE ,#PB_Entity_BoxBody , #PB_Entity_AbsoluteBodyMove)
    EntityPhysicBody(#DUDE ,#PB_Entity_SphereBody , #PB_Entity_AbsoluteBodyMove)
    SetEntityMass(#DUDE, 9.0)
    ;SetEntityFriction(#DUDE, 1.0)

    
    ;- CREATE CAMERA
    
    CreateCamera(#PLAYER, 0, 0, 100, 100)
      
    ; north wall
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; south wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, 200)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; east wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 200, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; west wall
    wx = 0
    For nx = 0 To 20
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ey = 0
    ez = 0
    ; now For a small test...
    times = Random(100) + 90 ; random number of objects between 90 and 190
    
    For whop = 0 To times
      x = Random(20)
      y = Random(20)
      maze(x,y) = Random(1)+2 ; random between 2 and 3 for now to place walls and doors
      Debug "SET = "+Str(times)
    Next
    ; * program still working
    
    ; *** read array to set the random walls and doors
    blocksize = 10
    Debug "=-=-=-=-=-=-   READING ARRAY!"
    For y=1 To mazeHeight-1
      For x=1 To mazeWidth-1
        If maze(x,y) = 2
          Result = CopyEntity(#DOOR, #PB_Any)
          EntityLocate(Result, x*blockSize, 0, y*blockSize)
          EntityPhysicBody(Result ,#PB_Entity_StaticBody)
          SetEntityMass(Result, 10.0)
          Debug "******  DOOR SET!"
        ElseIf maze(x,y) = 3
          Result = CopyEntity(#WALL, #PB_Any)
          EntityLocate(Result, x*blockSize, 0, y*blockSize)
          EntityPhysicBody(Result ,#PB_Entity_StaticBody)
          SetEntityMass(Result, 10.0)
          Debug "****** WALL SET!"
        EndIf
      Next
    Next
    Debug "<><><><><>< ARRAY READ"
    ; make sure there is a clear space for us to start on
    
    ;- hide the originals
    HideEntity(#WALL, #True)
    HideEntity(#DOOR, #True)
    HideEntity(#DUDE, #True)
    
    ; *** uncomment to see bounding boxes
    ;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    
    EnableWorldCollisions(1)
    EnableWorldPhysics(1)
    
    EntityLocate(#DUDE, 100,0,100)
    
    ;Fog(RGB(0,0,0), 1, 0, 50)
    WorldGravity(81.1)  ;EARTH // (91.1) ; MARSish
    ;- START OF LOOP
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
        
        ; ***** JUMP [ this truly does Not work well ]
        
        If KeyboardPushed(#PB_Key_Space)  
          EntityLocate(#DUDE, EntityX(#DUDE), 23, EntityZ(#DUDE))
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX - MouseDeltaX() / 2
        MouseY - MouseDeltaY() / 2
      EndIf
      
      PointPick(#PLAYER, ScreenWidth() / 2, ScreenHeight() / 2)
      
      RotateCamera(#PLAYER, MouseY, MouseX, 0, #PB_Absolute)
      RotateEntity(#DUDE, 0, MouseX, 0, #PB_Absolute)
      MoveEntity(#DUDE, -KeyY * PickX() - KeyX * PickZ(), 0, -KeyY * PickZ() + KeyX * PickX())
      CameraLocate(#PLAYER, EntityX(#DUDE), EntityY(#DUDE)+4, EntityZ(#DUDE))
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

I decided to use 1 LARGE tile for the floor... the #PLAYER still falls through at times... I turned on gravity as well... turned off FOG and whee!!! :mrgreen:

Re: OGRE First Person Code - Thoughts 15 MARCH 2011

Posted: Tue Mar 15, 2011 10:24 pm
by Rook Zimbabwe
new models here:
http://www.bluemesapc.com/Downloads/COLS.zip

I cannot for the life of me get wither the steps or the ramp to work no matter what density I set them to!!! :x

Re: OGRE FPS Code - Thoughts 15 MARCH 2011 (no ramp!)

Posted: Thu Mar 24, 2011 4:14 pm
by Rook Zimbabwe
apparently this code attempts to access the internet in some fashion. I have scanned the code well, I wrote some of it, and there is no request for internet access that I can fathom...

Likewise the program refuses even to RUN when compiled... InitEngine3D() fails in windows 7 X32

Covering this issue in WINDOWS forum.

Re: OGRE FPS Code - 26 MAR 2011 - Now with Compass!

Posted: Sat Mar 26, 2011 4:27 pm
by Rook Zimbabwe
Ok I have solved most of my problems. MOST.

This versionincludes a on screen compass... I didn't bother to include the images in the code as anyone here for more than 2 weeks should be ableto do that!

You are going to need:
Image

and

Image

for your BMP images...

Code: Select all


;
; ------------------------------------------------------------
;
;   PureBasic - Terrain -  modified by Ralph W Dunn / Rook ZImbabwe
;    (c) 2003 - Fantaisie Software
;    modified 25 MARCH 2011
;    Changes applied from examples by Daniel (Dark Dragon)
; ****** THIS IS MY ATTEMPT AT COMPASS
; ------------------------------------------------------------

version$ = "0.99"


#FLOOR = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALL = 5
#DOOR = 6
#COMPASS = 7
#NEEDLE = 8

#CameraSpeed = 15

; create an array to hold the junk

Global mazewidth = 30
Global mazeheight = 30
Global Dim maze(mazewidth,mazeheight)
; fill array with nothings
For x = 0 To mazewidth
  For y = 0 To mazeheight
    maze(x,y) = 0
  Next
Next

Procedure ScreenWidth()
  !extrn _PB_Screen_RealWidth
  !mov eax, dword [_PB_Screen_RealWidth]
  ProcedureReturn
EndProcedure

Procedure ScreenHeight()
  !extrn _PB_Screen_RealHeight
  !mov eax, dword [_PB_Screen_RealHeight]
  ProcedureReturn
EndProcedure

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
     Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
    InitKeyboard()
    InitMouse()
    InitSprite()
    InitSprite3D()
  
  EnableWorldPhysics(#True)
  EnableWorldCollisions(#True)
    
  ;If Screen3DRequester() ; commented out in thisinstance... simply uncomment to use and comment out below
    OpenScreen(800,600,32,"Dungeon Whump  "+version$,#PB_Screen_SmartSynchronization)
    ;- LOAD ENTITY
    ; load the compass graphics
    needle = LoadSprite(#PB_Any, "Arrow2.bmp", #PB_Sprite_Texture)
    CreateSprite3D(#NEEDLE, needle)
    compass = LoadSprite(#PB_Any, "compass03.bmp", #PB_Sprite_Texture)
    CreateSprite3D(#COMPASS, compass)
    
    Sprite3DQuality(1)
    
    LoadMesh(#FLOOR , "FLOR1.mesh")
    
    LoadMesh(#WALL , "CUBE1.mesh")
    LoadMesh(#DOOR, "DOOR1.mesh")
    LoadMesh(#DUDE, "GUY1.mesh") ; ****** our player for the node
    
    LoadTexture(0, "RUST1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL1.jpg") ; something to make it look nice
    LoadTexture(2, "terrain_texture.jpg") ; something to make it look nice
    
    walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
    DOORtex = CreateMaterial(#PB_Any, TextureID(0))
    floortex = CreateMaterial(#PB_Any, TextureID(2))
    ;CreateMaterial(#PB_Any, LoadTexture(1, "terrain_texture.jpg"))

    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(floortex))
    ScaleEntity(#FLOOR, 40, 0, 40)
    EntityLocate(#FLOOR, 150, -0.25, 150)
    EntityPhysicBody(#FLOOR ,#PB_Entity_StaticBody)
   ; SetEntityMass(#FLOOR, 10.0) ; uneccessary?
    
    CreateEntity(#WALL, MeshID(#WALL), MaterialID(walltex),0,0,0)
    CreateEntity(#DOOR, MeshID(#DOOR), MaterialID(DOORtex),0,0,0)
    
    CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),150,4,150)
    EntityPhysicBody(#DUDE ,#PB_Entity_SphereBody , #PB_Entity_AbsoluteBodyMove)
    SetEntityMass(#DUDE, 10.0)
    
    ;- CREATE CAMERA
    
    CreateCamera(#PLAYER, 0, 0, 100, 100)
      
    ; north wall
    For nx = 0 To 30
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
     ; SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; south wall
    wx = 0
    For nx = 0 To 30
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, wx, 0, 300)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      ;SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; east wall
    wx = 0
    For nx = 0 To 30
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 300, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
     ; SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; west wall
    wx = 0
    For nx = 0 To 30
      Result = CopyEntity(#WALL, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
    ;  SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ey = 0
    ez = 0
    ; now For a small test...
    
    times = 290 ; Random(150) + 90 ; random number of objects between 90 and 190
    
    For whop = 0 To times
      x = Random(30)
      y = Random(30)
      maze(x,y) = Random(1)+2 ; random between 2 and 3 for now to place walls and doors
      Debug "SET = "+Str(times)
    Next
    
    ; *** read array to set the random walls and doors
    blocksize = 10
    Debug "=-=-=-=-=-=-   READING ARRAY!"
    For y=1 To mazeHeight-1
      For x=1 To mazeWidth-1
        If x+y <> 300 ; attempt at making sure a clear space for starting out X = 150 Y = 150
         If maze(x,y) = 2
           Result = CopyEntity(#DOOR, #PB_Any)
           EntityLocate(Result, x*blockSize, 0, y*blockSize)
           EntityPhysicBody(Result ,#PB_Entity_StaticBody)
         ; SetEntityMass(Result, 10.0)
         ElseIf maze(x,y) = 3
            Result = CopyEntity(#WALL, #PB_Any)
           EntityLocate(Result, x*blockSize, 0, y*blockSize)
           EntityPhysicBody(Result ,#PB_Entity_StaticBody)
       ;   SetEntityMass(Result, 10.0)
      EndIf
     EndIf
      Next
    Next
    Debug "<><><><><>< ARRAY READ"
    ; make sure there is a clear space for us to start on
    
    ;- hide the originals
    HideEntity(#WALL, #True)
    HideEntity(#DOOR, #True)
    HideEntity(#DUDE, #True)
    
    ; *** uncomment to see bounding boxes
    ;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    
    EntityLocate(#DUDE, 150,0,150) ; X and Y (ok technically Z) = 300 for centering see line 164
    
    ;Fog(RGB(0,0,0), 1, 0, 50) ; uncomment for more spooky!
    
    WorldGravity(81.1)  ;EARTH // (91.1) ; MARSish - enh!
    ;- START OF LOOP
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
        
        ; ***** JUMP [ this truly does Not work well ] but included in case you fall through FLOOR
        
        If KeyboardPushed(#PB_Key_Space)  
          EntityLocate(#DUDE, EntityX(#DUDE), 23, EntityZ(#DUDE))
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX - MouseDeltaX() / 4 ; I wish there was a way to slow down mouselook...
        MouseY - MouseDeltaY() / 4
      EndIf
      
      PointPick(#PLAYER, ScreenWidth() / 2, ScreenHeight() / 2)
      
      RotateCamera(#PLAYER, MouseY, MouseX, 0, #PB_Absolute)
      RotateEntity(#DUDE, 0, MouseX, 0, #PB_Absolute)
      MoveEntity(#DUDE, -KeyY * PickX() - KeyX * PickZ(), 0, -KeyY * PickZ() + KeyX * PickX())
      CameraLocate(#PLAYER, EntityX(#DUDE), EntityY(#DUDE)+4, EntityZ(#DUDE))
      
      RenderWorld()
      ; this is where you use Sprite3D stuff
      Start3D()
      DisplaySprite3D(#COMPASS, 0,470);  draw back first
      RotateSprite3D(#NEEDLE, MouseX, 0) ; set needle
      DisplaySprite3D(#NEEDLE, 0,470); then draw it
      Stop3D()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
 ; UNCOMMENT below if using screenrequester
;Else
 ; MessageRequester("Error", "The 3D Engine can't be initialized",0)
;EndIf

End
runs in fullscreen... you can uncomment the screenrequester code and change that... I also reccomend tunring ON the fog (line 192 or thereabouts) as it adds a bit of spooky feel! :mrgreen:

Re: OGRE FPS Code - 26 MAR 2011 - Now with Compass!

Posted: Sat Mar 26, 2011 5:58 pm
by djes
Could you make a zip, please?

Re: OGRE FPS Code - 26 MAR 2011 - Now with Compass!

Posted: Sun Mar 27, 2011 5:22 pm
by Rook Zimbabwe
entire folder (minus .dll which you can supply) is at:
http://www.bluemesapc.com/Downloads/COMPASS.zip

it will be up till end of march. Gotta clean house on the website! :mrgreen: