Dungeon raider (game demo)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Dungeon raider (game demo)

Post by applePi »

thanks DK_PETER for testing, i have found another amazing feature, if we give the flattened sphere physics property it will have a rigid physical body so the balls can float over it. i have used the official example "C:\PureBasic\Examples\3D\Bridge.pb" the balls and cubes are jumping over the flattened sphere and ride its waves, the object are given mass 0 so to stay static in its place
Edit:i think now the reason of the flattened sphere that we have used only x,z
xa.f=MeshData(c)\x
zb.f=MeshData(c)\z

and that we set the MeshData(c)\y to some formula not what is necessary for making the sphere so we get the 2D surface with the wave represented by MeshData(c)\y
the related parts of my tests begins from line 113 ;the flatten sphere + the procedure UpdateMatrix
more investigation needed.

Image

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - PointJoint (Bridge)
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

#CameraSpeed = 1
#NbPlanks = 30
#NbX=30
#NbZ=30

Global Dim MeshData.PB_MeshVertex(0)
Global Dim MeshDataInd.PB_MeshFace(0)

Declare UpdateMatrix()

Define.f KeyX, KeyY, MouseX, MouseY
Dim Plank(#NbPlanks)

If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts",#PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    WorldShadows(#PB_Shadow_Modulative, -1, RGB(127, 127, 127))
    
    ;Materials
    ;
    CreateMaterial(0, LoadTexture(0, "Wood.jpg"))
    GetScriptMaterial(1, "SphereMap/SphereMappedRustySteel")
    CreateMaterial(2, LoadTexture(2, "Dirt.jpg"))
    GetScriptMaterial(3, "Scene/GroundBlend")
    
    ; Ground
    ;
    CreatePlane(3, 500, 500, 5, 5, 5, 5)
    CreateEntity(3,MeshID(3),MaterialID(3), 0, -50, 0)
    EntityRenderMode(3, 0) 
    EntityPhysicBody(3, #PB_Entity_BoxBody, 0, 1, 1)
    
    ; Bridge
    CreateCube(1, 1.0)
    For i = 1 To #NbPlanks
      Plank(i)=CreateEntity(#PB_Any, MeshID(1), MaterialID(0))
      ScaleEntity(Plank(i), 2.8, 0.8, 20)
      MoveEntity(Plank(i), i * 3, 0, 0, #PB_Absolute)
      EntityPhysicBody(Plank(i), #PB_Entity_BoxBody, 1.0)
    Next i
    
    Pas.f = 1.5
    PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, -5)
    For i= 1 To #NbPlanks-2
      Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)), -Pas, 0, -5, EntityID(Plank(i)), Pas, 0, -5)
    Next i
    PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)),  Pas, 0, -5)
    PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)),  Pas, 0, -5, EntityID(Plank(#NbPlanks)), -Pas, 0, -5)
    
    PointJoint(#PB_Any, EntityID(Plank(1)), -Pas, 0, 5)
    For i= 1 To #NbPlanks-2
      Joint=PointJoint(#PB_Any, EntityID(Plank(i+1)),  -Pas, 0, 5, EntityID(Plank(i)), Pas, 0, 5)
    Next i
    PointJoint(#PB_Any, EntityID(Plank(#NbPlanks)),  Pas, 0, 5)
    toto=PointJoint(#PB_Any, EntityID(Plank(#NbPlanks-1)),  Pas, 0, 5, EntityID(Plank(#NbPlanks)), -Pas, 0, 5)
    
    ; Objects
    ;
    CreateSphere(2, 2, 30, 30)
    
    C = Plank(1)
    For i = 1 To #NbPlanks/2
      Perso = CreateEntity(#PB_Any, MeshID(2), MaterialID(1), EntityX(C) +i * 5, EntityY(C)+ i * 2, EntityZ(C))
      EntityPhysicBody(Perso, #PB_Entity_SphereBody, 1.0, 0.3, 0.5)
    Next i
    
    For i = 1 To #NbPlanks/2
      Perso = CreateEntity(#PB_Any, MeshID(1), MaterialID(2), EntityX(C) +i * 5, EntityY(C)+ i * 4, EntityZ(C))
      ScaleEntity(Perso, 3, 3, 3)
      EntityPhysicBody(Perso, #PB_Entity_BoxBody, 1.0)
    Next i
    
    ; Camera
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, -20, 60, -140, #PB_Absolute)
    CameraLookAt(0, EntityX(C) + 45, EntityY(C) + 10,  EntityZ(C))
    
    ; Skybox
    ;
    SkyBox("desert07.jpg")
    
    ; Light
    ;
    CreateLight(0, RGB(255, 255, 255), 100, 800, -500)
    AmbientColor(RGB(255, 255, 255))
    
    Plank = 1
    
    
  ;the flatten sphere  
  CreateMaterial(4, LoadTexture(4, "white.jpg"))
  MaterialShadingMode(4, #PB_Material_Wireframe)  
  CreateSphere(0,20,30,30)
  CreateEntity(0, MeshID(0), MaterialID(4), 70,10,0)
  
  ScaleEntity(0, 3, 0.1, 3)
  EntityPhysicBody(0, #PB_Entity_ConvexHullBody , 0, 1, 1)
  
  GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0, 0)-1)
  ;GetMeshData(0,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(0, 0)-1)
    
    Repeat
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If ExamineKeyboard()
        If KeyboardReleased(#PB_Key_W)
          MaterialShadingMode(4, #PB_Material_Wireframe)
        ElseIf KeyboardReleased(#PB_Key_S)
          MaterialShadingMode(4, #PB_Material_Solid)
        EndIf
        
        If KeyboardPushed(#PB_Key_Space)
          ApplyEntityImpulse(Plank(#NbPlanks/2), 0, 9, 0)
        EndIf
        If KeyboardReleased(#PB_Key_Return)
          
          If Plank <= #NbPlanks
            DisableEntityBody(Plank(Plank), 0)
            FreeEntityJoints(Plank(Plank))
            Plank + 1  
          EndIf  
          
        EndIf      
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)
      RotateEntity(0, 0,0.2,0, #PB_Relative)
      ; Waves
      UpdateMatrix()
      
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
    
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End


Procedure UpdateMatrix()
 
  dtime.f=ElapsedMilliseconds()/600 ; reduce 600 to get speedier animation
  
  For b=0 To #Nbz
    For a=0 To #NbX
      xa.f=MeshData(c)\x
      zb.f=MeshData(c)\z
      ;yy.f= MeshData(c)\y
      ;new y vertex coordinates
      MeshData(c)\y=yy+Cos(dtime + (Sqr(Pow(0.5*xa,2)+Pow(0.5*zb,2))))*20
      
      c + 1 ; vertex number

    Next a
  Next b
  
  SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Normal, 0, MeshVertexCount(0, 0)-1)
  EntityPhysicBody(0, #PB_Entity_ConvexHullBody , 0, 1, 1)
EndProcedure
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Dungeon raider (game demo)

Post by DK_PETER »

@applePi

Very nice. Looks even more interesting when you change mass and friction to the 'sphere'.
You should post the examples in a 3D thread instead of doing it here.
They are worth adding there.

Edit: I tried this:
MeshData(c)\y=yy+Cos(dtime + (Sqr(Pow(0.7*xa,2)+Pow(0.4*zb,2))))*50
and
EntityPhysicBody(0, #PB_Entity_ConvexHullBody , 1, 1, 1)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
ElementE
Enthusiast
Enthusiast
Posts: 139
Joined: Sun Feb 22, 2015 2:33 am

Re: Dungeon raider (game demo)

Post by ElementE »

Hi AndyLy,
The game demos look very good.

I would like to get the source, but both of the download links in the first post don't work.
Could you please upload again?
Think Unicode!
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

ElementE
I do not share the source . I laid out the demo (old version).
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
ElementE
Enthusiast
Enthusiast
Posts: 139
Joined: Sun Feb 22, 2015 2:33 am

Re: Dungeon raider (game demo)

Post by ElementE »

AndyLy wrote:ElementE
I do not share the source . I laid out the demo (old version).
I understand AndyLy.
I like the way you have the player descend down to the secret industrial center.
It is very interesting to encounter the various machines and finding items to pickup for the player's inventory.
It is also fun to be surprised by the automated sentinel that protects against intruders. That keeps things exciting.
I hope you decide to release the full playable game in the future.

Now, I have to learn how to use PureBasic to make 3D games! :)
Think Unicode!
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

Now, I have to learn how to use PureBasic to make 3D games!
I do not advise. This is hemorrhoids. )
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

Demo :
https://drive.google.com/file/d/0Bzlktr ... sp=sharing

in the root folder there is a small help.txt
in folder docs description of work with the types of objects and other things.

P.S. I had to compile in 32 system because the program compiled in 64 - works much slower !?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: Dungeon raider (game demo)

Post by mpz »

Hi AndyLy,

thanks for the cool demo. You have made a nice atmosphere and things in the rooms.

Question:
I come down the room with 4 doors and there is a way with laser beam. How can a deactivate them? I tested everything but cant find a way out. I find a the puzzle on the wall with three switches but they dont have any effect?!?...


Greetings Michael

P.S:
I love dungeons, my first Amiga Game was "Dungeon Master"
https://www.youtube.com/watch?v=-VSVaJOemEU
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

Hi Michael, thanks for feedback.
I come down the room with 4 doors and there is a way with laser beam. How can a deactivate them?
The switch is located behind the barrier. You have to find a way to destroy it, to turn off the barrier.
But behind the barrier there is nothing at the moment.
I find a the puzzle on the wall with three switches but they dont have any effect?!?
When turn on all three lights - start working a fan in the room with poison gas. Maybe it will help clear the air?...
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
ElementE
Enthusiast
Enthusiast
Posts: 139
Joined: Sun Feb 22, 2015 2:33 am

Re: Dungeon raider (game demo)

Post by ElementE »

Thank you AndyLy for making your game available.
I am having a problem.
When the game is started, it fails during initialization. The error messages reported in the log file are:
Start load scene gnss_station_gr.scn
! ! ! Fatal runtime error ! (string num 29)
! Error type : Invalid memory access (string num 29)
! Filename : SMSF_town_module_51.pb (string num 29)
! Error line : 1058 (string num 29)
Program aborted ! 11/25/2015 10:16:01
The computer I am using is a Windows 7, 64-bit machine with 8gb RAM.
I also had the error when using a Windows Vista computer.
Think Unicode!
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

ElementE
The error occurs at the beginning of the download scene when trying to create the entity from the mesh and material.
So it's hard to say, can be anything (drivers, Direct X, my code...).
System may not like this particular object. Open file \data\scene\gnss_station_gr.scn and remove string :

Code: Select all

object=jeep_1,2.912,0.776,-22.169,-1.8,183.0,2.9,1.00,1.00,1.00,1
But I do not think that this will help.

p.s. Or inserted after the lines

Code: Select all

object=twn_trade_sky_1,0,0,0,0,0,0,512,48,512,0
object=twn_trade_sky_2,0,0,0,0,0,0,520,52,520,0
object=terr_hill_2,0,0,0,0,0,0,10,8,10,1
Command
comment_start
And at the end of the file
comment_end
Let's see Is the program will start working.
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
ElementE
Enthusiast
Enthusiast
Posts: 139
Joined: Sun Feb 22, 2015 2:33 am

Re: Dungeon raider (game demo)

Post by ElementE »

AndyLy wrote:ElementE
The error occurs at the beginning of the download scene when trying to create the entity from the mesh and material.
So it's hard to say, can be anything (drivers, Direct X, my code...).
System may not like this particular object. Open file \data\scene\gnss_station_gr.scn and remove string :

Code: Select all

object=jeep_1,2.912,0.776,-22.169,-1.8,183.0,2.9,1.00,1.00,1.00,1
But I do not think that this will help.

p.s. Or inserted after the lines

Code: Select all

object=twn_trade_sky_1,0,0,0,0,0,0,512,48,512,0
object=twn_trade_sky_2,0,0,0,0,0,0,520,52,520,0
object=terr_hill_2,0,0,0,0,0,0,10,8,10,1
Command
comment_start
And at the end of the file
comment_end
Let's see Is the program will start working.
Removing the line

Code: Select all

object=jeep_1,2.912,0.776,-22.169,-1.8,183.0,2.9,1.00,1.00,1.00,1
did not work.
Error messages generated:
Start load scene gnss_station_gr.scn
! ! ! Fatal runtime error ! (string num 30)
! Error type : Invalid memory access (string num 30)
! Filename : SMSF_town_module_51.pb (string num 30)
! Error line : 1058 (string num 30)
Program aborted ! 11/25/2015 11:25:16
Placing "comment_start" and "comment_end" in the file at the places you indicate also did not work. The error messages generated are:
Start load scene gnss_station_gr.scn
Scene time to load : 0.30 s , VMem use=394 mb
Loaded : objects 4, meshes 5, textures 11
Error count : 0
Start game ------------------------------------------------------
Set World shadows : 1
! ! ! Fatal runtime error ! (string num 610)
! Error type : Invalid memory access (string num 610)
! Filename : SMSF_town_module_51.pb (string num 610)
! Error line : 4822 (string num 610)
Program aborted ! 11/25/2015 11:21:37
Think Unicode!
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Dungeon raider (game demo)

Post by AndyLy »

The latter possibility. )
Comment out or delete this line (in \data\scene\gnss_station_gr.scn):

Code: Select all

start_clip=gnss_ground_1_start,30
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
ElementE
Enthusiast
Enthusiast
Posts: 139
Joined: Sun Feb 22, 2015 2:33 am

Re: Dungeon raider (game demo)

Post by ElementE »

AndyLy wrote:The latter possibility. )
Comment out or delete this line (in \data\scene\gnss_station_gr.scn):

Code: Select all

start_clip=gnss_ground_1_start,30
Still does not work.
Error messages now read:
Start load scene gnss_station_gr.scn
! ! ! Fatal runtime error ! (string num 29)
! Error type : Invalid memory access (string num 29)
! Filename : SMSF_town_module_51.pb (string num 29)
! Error line : 1058 (string num 29)
Program aborted !
Think Unicode!
Post Reply