Page 4 of 6

Re: Dungeon raider (game demo)

Posted: Wed Dec 31, 2014 10:29 am
by Bananenfreak
Very nice! Good work, AndyLy.
I like the day-night-cycle with sunmovement and the NPC.

A few question: When there´s rain, is there also rain IN buildings? Or did you find a way to prevent that?
This firecans are very realistic... Could you please share the colors you used for it :)

Everytime you post a Thing of your game (or games?) I feel bad, because I´m not as fast as you program those things :)

Re: Dungeon raider (game demo)

Posted: Wed Dec 31, 2014 1:03 pm
by AndyLy
Bananenfreak
When there´s rain, is there also rain IN buildings? Or did you find a way to prevent that?
Yes, there is rain in buildings too. And yes, you can prevent it. But it will load the home computers (check for collision).
Everytime you post a Thing of your game (or games?) I feel bad, because I´m not as fast as you program those things
I have long started to make my program. I started on MPZ, then moved on Ogre. So, not so fast.
Could you please share the colors you used for it
Not quite sure about what colors you're talking about.
I use this sprite https://www.dropbox.com/s/hzybq73owivdp ... 1.jpg?dl=0

Re: Dungeon raider (game demo)

Posted: Wed Dec 31, 2014 2:04 pm
by AndyLy
All that I've posted before - it's parts of the game .
There is a main block (strategic), in which you build a town(s), collect resources, build an army combat vehicles, and more. This block in 2D format.
When you are traveling on the map - you are visiting different locations - a separate window in the 3D format.
Now there are three types of locations - towns, dungeons and locations for the battle droids.

I'm doing a game with an open architecture (as I understand it).
If you look at the files in the folder "data", you will see that there is a description and configuration for all.
That is, now you can change or add new types of objects. Modify or create a new scene... You can make a lot of things.
There is only one problem - there is no documentation. Any. Nowhere. At least in our galaxy.

Re: Dungeon raider (game demo)

Posted: Wed Dec 31, 2014 7:02 pm
by Danilo
Bananenfreak wrote:This firecans are very realistic... Could you please share the colors you used for it :)
Also check out Timeline FX particle editor and the Effects Libraries that come with it.

You can make Sprite Sheets, Animation Strips, and export separate files as a sequence of images. Use it for PB animated sprites/billboards/textures. ;)

Re: Dungeon raider (game demo)

Posted: Thu Jan 01, 2015 3:25 pm
by AndyLy
Or do not buy, do it yourself. Nice and easy.
for example

Code: Select all

material anim_exp_mat_1
{
	technique
	{
		pass
		{
			scene_blend alpha_blend
			depth_write off
			lighting off
 			diffuse 1.0 1.0 1.0 0.9
			texture_unit
			{	
				anim_texture anim_exp.png 8 0.8
			}
		}
	}
}

Code: Select all

particle_system exp_anim_1
{
    material anim_exp_mat_1
    particle_width 8
    particle_height 8
    cull_each false
    quota 100
    billboard_rotation_type vertex

 emitter Point
    {
        angle 180
        emission_rate 15
         time_to_live_min 0.75
         time_to_live_max 0.75
        direction 0 1 0
        velocity_min 1.6
        velocity_max 2.0
       duration 0.4
    }

    affector ColourFader
    {
        red 0
        green 0
        blue 0
        alpha -2.0	
    }

	affector Scaler
	{
    	rate 36
	}

	affector Rotator
	{
    	      rotation_speed_range_start 5
	      rotation_speed_range_end 80
	      rotation_range_start 0
	      rotation_range_end 360
	}
}
Sprites
https://www.dropbox.com/s/xb16zldsbglao ... 3.rar?dl=0

Re: Dungeon raider (game demo)

Posted: Sat Apr 18, 2015 2:54 pm
by AndyLy
Demo
Space - action with
Caps - jump
window res - data/config.cfg
string window_width_height=
https://yadi.sk/d/46hlBfxAg5TdR

Re: Dungeon raider (game demo)

Posted: Wed Apr 22, 2015 8:33 am
by applePi
Hi AndyLy
what you have used for the water ??, it seems to me a confined water and not unlimited, as an example can you have water in a pot, such as a tea cup ?
your demo run in windows 7 speedier and better than in windows xp. the graphics flicker when we move left and right, my vga card is Geforce GT 520. it is possible the flicker is because the water exhaust more cpu/gpu power. it is may be needs a more powerful computer because of the heavy graphics used. when we aim and shoot the bullet go not in exact place.
i like the flame under the space ship and the occasional tree leaves on the ground fly with wind good idea. i suggest to add something like a flying saucer (UFO) .
in general it is a good attempt.

Re: Dungeon raider (game demo)

Posted: Sat Apr 25, 2015 5:47 pm
by AndyLy
applePi
Thanks for your answer.
This water - mesh (plane) with update. I found the code here on the forum, but can't remember exactly where. It was something like a flag in the wind or something.
And yes - you can do it any size, but square.
I'm not an expert in operating system, so I don't know why it work slowly in XP.

Re: Dungeon raider (game demo)

Posted: Sun Apr 26, 2015 12:30 pm
by DK_PETER
@AndyLy

Nicely done. I too experience some minor jaggedness when moving sideways. (GTX 770 4GB - Windows 7 64 bit)

@ApplePi
I think AndyLy used this one made by our good and friendly acquaintance, Comtois:
http://www.purebasic.fr/english/viewtop ... =mesh+wave

When he made it, I converted it to a module.

Code: Select all

IncludeFile #PB_Compiler_Home + "Examples\3D\Screen3DRequester.pb"

DeclareModule _xwave
  Declare.i Init() ;Reset Values
  Declare.i UpdateWave()
  Declare.i AddWave(Material.i, SizeX.i = 30, SizeZ.i = 30, ScaleValueX.f = 3, ScaleValueY.f = 3, ScaleValueZ.f = 3)
  Declare.i RemoveWave()
  Declare.i SetWaveFrequency(value.f = 1)
  Declare.f GetWaveFrequency()
  Declare.i SetWavePeriodX(value.f = 4)
  Declare.f GetWavePeriodX()
  Declare.i SetWavePeriodZ(value.f = 5)
  Declare.f GetWavePeriodZ()
  Declare.i SetWaveAmplitude(value.f = 2)
  Declare.f GetWaveAmplitude()
  Declare.i SetWaveAngle(Angle.f)
  Declare.f GetWaveAngle()
  Declare.i GetWaveEntityID()
  Declare.i GetWaveMeshID()
EndDeclareModule

Module _xwave
  
  Structure Vector3
    x.f
    y.f
    z.f
  EndStructure
  
  Macro SubVector3(n, v, w)
    n\x = v\x - w\x
    n\y = v\y - w\y
    n\z = v\z - w\z
  EndMacro
  
  Structure _waveBase
    Normal.Vector3
    v1.Vector3
    v2.Vector3
    v3.Vector3
    WaveFrequency.f
    WavePeriodX.f
    WavePeriodZ.f
    WaveAmplitude.f
    WaveAngle.f
    MeshSizeX.i
    MeshSizeZ.i
    ScaleX.f
    ScaleY.f
    ScaleZ.f
    ID.i
    Mesh.i
    tex.i
    Mat.i
  EndStructure   
  
  Global Dim MeshData.PB_MeshVertex(0)
  Global Dim MeshDataInd.PB_MeshFace(0)
  Global wave._waveBase
  
  Procedure.i Init()
    wave\WaveFrequency = 4  ;=waves/second
    wave\WavePeriodX   = 4  ;=1/Wave lenght
    wave\WavePeriodZ   = 5  ;=1/Wave lenght
    wave\WaveAmplitude = 2
  EndProcedure
  
  Procedure.i SetWaveAngle(Angle.f)
    If Angle < 0 Or Angle > 359
      Angle = 0
    EndIf
    wave\WaveAngle = Angle
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWaveAngle()
    ProcedureReturn wave\WaveAngle
  EndProcedure
  
  Procedure.i SetWaveFrequency(value.f = 1)
    wave\WaveFrequency = value
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWaveFrequency()
    ProcedureReturn wave\WaveFrequency
  EndProcedure
  
  Procedure.i SetWavePeriodX(value.f = 4)
    wave\WavePeriodX = value
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWavePeriodX()
    ProcedureReturn wave\WavePeriodX
  EndProcedure
  
  Procedure.i SetWavePeriodZ(value.f = 5)
    wave\WavePeriodZ = value
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWavePeriodZ()
    ProcedureReturn wave\WavePeriodZ
  EndProcedure
  
  Procedure.i SetWaveAmplitude(value.f = 2)
    wave\WaveAmplitude = value
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWaveAmplitude()
    ProcedureReturn wave\WaveAmplitude  
  EndProcedure
  
  Procedure.i SetWaveAngleValue(value = 0)
    wave\WaveAngle = value
    ProcedureReturn #True
  EndProcedure
  
  Procedure.f GetWaveAngleValue(WaveID.i)
    ProcedureReturn wave\WaveAngle
  EndProcedure
  
  Procedure.i GetWaveEntityID()
    ProcedureReturn wave\ID
  EndProcedure
  
  Procedure.i GetWaveMeshID()
    ProcedureReturn wave\Mesh
  EndProcedure
  
  Procedure Normalize(*V.Vector3)
    Protected.f magSq, oneOverMag
    magSq = *V\x * *V\x + *V\y * *V\y + *V\z * *V\z
    If magsq > 0
      oneOverMag = 1.0 / Sqr(magSq)
      *V\x * oneOverMag
      *V\y * oneOverMag
      *V\z * oneOverMag
    EndIf
  EndProcedure
  
  Procedure NormalFace(*n.Vector3, *v1.Vector3, *v2.Vector3, *v3.Vector3)
    Protected.Vector3 v2v1, v3v1
    SubVector3(v2v1, *v2, *v1)
    SubVector3(v3v1, *v3, *v1)
    
    *n\x = v2v1\y * v3v1\z - v2v1\z * v3v1\y
    *n\y = v2v1\z * v3v1\x - v2v1\x * v3v1\z
    *n\z = v2v1\x * v3v1\y - v2v1\y * v3v1\x
  EndProcedure 
  
  Procedure DrawMatrix()
    Protected.l a, b, c, Nb
    Protected.w P1, P2, P3, P4
    With wave
      For b=0 To \MeshSizeZ
        For a=0 To \MeshSizeX
          y.f=Sin(Radian((\WaveAngle + a * \WavePeriodX + b * \WavePeriodZ))) * \WaveAmplitude
          MeshVertexPosition(a - \MeshSizeX / 2, y, b - \MeshSizeZ / 2)
          MeshVertexNormal(0, 1, 0)
          MeshVertexTextureCoordinate(a / \MeshSizeX, b / \MeshSizeZ)
        Next a
      Next b
      
      Nb=\MeshSizeX+1
      For b=0 To \MeshSizeZ-1
        For a=0 To \MeshSizeX-1
          P1=a+(b*Nb)
          P2=P1+1
          P3=a+(b+1)*Nb
          P4=P3+1
          
          MeshFace(P3, P2, P1)
          MeshFace(P2, P3, P4)
        Next
      Next
    EndWith
  EndProcedure
  
  Procedure.i AddWave(Material.i, SizeX.i = 30, SizeZ.i = 30, ScaleValueX.f = 3, ScaleValueY.f = 3, ScaleValueZ.f = 3)
    With wave
      
      \MeshSizeX = SizeX : \MeshSizeZ = SizeZ
      If Mesh <> -1
        CreateMesh(Mesh, #PB_Mesh_TriangleList, #True)
      Else
        Mesh = CreateMesh(#PB_Any, #PB_Mesh_TriangleList, #True)
      EndIf
      \Mesh = Mesh
      DrawMatrix()
      FinishMesh(#True)
      SetMeshMaterial(\Mesh, MaterialID(Material))
      \ID = CreateEntity(#PB_Any, MeshID(\Mesh), #PB_Material_None)
      \ScaleX = ScaleValueX : \ScaleY = ScaleValueY : \ScaleZ = ScaleValueZ
      ScaleEntity(\ID, ScaleValueX, ScaleValueY, ScaleValueZ)
      GetMeshData(\Mesh, 0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(\Mesh, 0)-1)
      GetMeshData(\Mesh, 0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(\Mesh, 0)-1)
    EndWith
    
  EndProcedure
  
  Procedure.i RemoveWave()
    If IsEntity(wave\ID)
      FreeEntity(wave\ID)
    EndIf
    If IsMesh(wave\Mesh)
      FreeMesh(wave\Mesh)
    EndIf
    ReDim MeshData(0)
    ReDim MeshDataInd(0)
  EndProcedure
  
  Procedure.i UpdateWave()
    Protected a, b, c, i, j
    Protected N.Vector3, V1.Vector3, V2.Vector3, V3.Vector3
    Protected.f magSq, oneOverMag
    
    With wave
      For b=0 To \MeshSizeZ
        For a=0 To \MeshSizeX
          MeshData(c)\y = Sin(Radian((\WaveAngle + a * \WavePeriodX + b * \WavePeriodZ))) * \WaveAmplitude
          MeshData(c)\NormalX = 0
          MeshData(c)\NormalY = 0
          MeshData(c)\NormalZ = 0
          c + 1
        Next a
      Next b

      For j=0 To ArraySize(MeshDataInd())-2 Step 3
        
        V1\x = MeshData(MeshDataInd(j  )\Index)\x
        V1\y = MeshData(MeshDataInd(j  )\Index)\y
        V1\z = MeshData(MeshDataInd(j  )\Index)\z
        V2\x = MeshData(MeshDataInd(j+1)\Index)\x
        V2\y = MeshData(MeshDataInd(j+1)\Index)\y
        V2\z = MeshData(MeshDataInd(j+1)\Index)\z 
        V3\x = MeshData(MeshDataInd(j+2)\Index)\x
        V3\y = MeshData(MeshDataInd(j+2)\Index)\y
        V3\z = MeshData(MeshDataInd(j+2)\Index)\z   
        NormalFace(@N, @V1, @V2, @V3)
        ;Normalize(@N)
        MeshData(MeshDataInd(j  )\Index)\NormalX + N\x
        MeshData(MeshDataInd(j  )\Index)\NormalY + N\y
        MeshData(MeshDataInd(j  )\Index)\NormalZ + N\z
        MeshData(MeshDataInd(j+1)\Index)\NormalX + N\x
        MeshData(MeshDataInd(j+1)\Index)\NormalY + N\y
        MeshData(MeshDataInd(j+1)\Index)\NormalZ + N\z 
        MeshData(MeshDataInd(j+2)\Index)\NormalX + N\x
        MeshData(MeshDataInd(j+2)\Index)\NormalY + N\y
        MeshData(MeshDataInd(j+2)\Index)\NormalZ + N\z     
      Next
      
      For i=0 To ArraySize(MeshData())
        
        magSq = MeshData(i)\NormalX * MeshData(i)\NormalX +
                MeshData(i)\NormalY * MeshData(i)\NormalY +
                MeshData(i)\NormalZ * MeshData(i)\NormalZ
        
        If magsq > 0
          oneOverMag = 1.0 / Sqr(magSq)
          MeshData(i)\NormalX * oneOverMag
          MeshData(i)\NormalY * oneOverMag
          MeshData(i)\NormalZ * oneOverMag
        EndIf
        
      Next
      SetMeshData(wave\Mesh, 0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Normal, 0, MeshVertexCount(wave\Mesh, 0)-1)
    EndWith  
  EndProcedure
  
EndModule



#CameraSpeed = 1

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data/Textures", #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data/Packs/skybox.zip", #PB_3DArchive_Zip)
    Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data/Scripts", #PB_3DArchive_FileSystem)
    Parse3DScripts()
    
    ;-Material
    CreateMaterial(1, LoadTexture(1, "MRAMOR6X6.jpg"))
    MaterialCullingMode(1, 1)
    
    ;-Mesh
    _xwave::Init()
    _xwave::AddWave(1)
    
    ;-Camera
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,0,150,80, #PB_Absolute)
    CameraLookAt(0, 0, 0, 0)
    CameraBackColor(0, RGB(90, 0, 0))
    
    ;-Light
    CreateLight(0, RGB(255, 255, 255), 5, 15, 5)
    AmbientColor(RGB(30, 30, 30))
    
    ;- Skybox
    SkyBox("stevecube.jpg")
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()
        
        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
        
        If KeyboardReleased(#PB_Key_F2)
          _xwave::SetWaveAngle(_xwave::GetWaveAngle() - 1)
        ElseIf KeyboardReleased(#PB_Key_F3)
          _xwave::SetWaveAngle(_xwave::GetWaveAngle() + 1)
        EndIf          
        
        If KeyboardReleased(#PB_Key_F4)
          _xwave::SetWaveAmplitude(_xwave::GetWaveAmplitude() - 1)
        ElseIf KeyboardReleased(#PB_Key_F5)
          _xwave::SetWaveAmplitude(_xwave::GetWaveAmplitude() + 1)
        EndIf   
        
        If KeyboardReleased(#PB_Key_F6)
          _xwave::SetWaveFrequency(_xwave::GetWaveFrequency() - 1)
        ElseIf KeyboardReleased(#PB_Key_F7)
          _xwave::SetWaveFrequency(_xwave::GetWaveFrequency() + 1)
        EndIf 
        
        If KeyboardReleased(#PB_Key_F8)
          _xwave::SetWavePeriodX(_xwave::GetWavePeriodX() - 1)
        ElseIf KeyboardReleased(#PB_Key_F9)
          _xwave::SetWavePeriodX(_xwave::GetWavePeriodX() + 1)
        EndIf 
        
        If KeyboardReleased(#PB_Key_F11)
          _xwave::SetWavePeriodZ(_xwave::GetWavePeriodZ() - 1)
        ElseIf KeyboardReleased(#PB_Key_F12)
          _xwave::SetWavePeriodZ(_xwave::GetWavePeriodZ() + 1)
        EndIf 
        
        If KeyboardReleased(#PB_Key_Space)
          _xwave::Init() ;reset to basic
        EndIf
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)
        MouseY = -(MouseDeltaY()/10)
      EndIf
      
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      
      ; Waves
      _xwave::UpdateWave()
      _xwave::SetWaveAngle(_xwave::GetWaveAngle() + _xwave::GetWaveFrequency())
      
      RenderWorld()
      
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End

Re: Dungeon raider (game demo)

Posted: Sun Apr 26, 2015 3:40 pm
by applePi
thanks DK_PETER for the info and the code converted to a module , i remember that thread , and remember that it resembles water so i had posted then "Addon toys for MeshManualFlag example" http://purebasic.fr/english/viewtopic.php?f=36&t=52687 there is a sphere over the flag which we can move by arrows as if it is floating over water. but then abandoned the project. what makes AndyLy water interesting is the Lake waves simulation like this image
Image
the waves wiggle calmly and the borders of the Lake deforms as in the tide on the sea shore.
so 1- deformation of the 2D mesh on its edges as if it is an Amoeba, 2- a suitable water equation or equations 3- some random feature to apply over the water equation. 4- color, alpha, textures .... certainly a big work
the slowness in the AndyLy demo may be caused by the continuous animation of water mesh even if it is not on the sight of the player, just a guess.
there is a good ocean simulator posted by idle years ago http://purebasic.fr/english/viewtopic.p ... 3&p=394537
http://purebasic.fr/english/viewtopic.p ... 1&p=441382
but it needs now correction to work with PB 5.31

Re: Dungeon raider (game demo)

Posted: Sun Apr 26, 2015 5:11 pm
by AndyLy
I conducted tests and found that most computer loads - is the number of objects.
I do not know why, but Ogre calculates all the objects in the visual field, regardless of whether I see them or not.
There is only one capable to reduce the maximum range of the camera.
But I had a bag- max. distance the camera does not work, only the minimum.

Re: Dungeon raider (game demo)

Posted: Mon Apr 27, 2015 9:32 am
by Bananenfreak
AndyLy,
you could use static geometries to bundle your static objects so you only have one batch instead of multiple ones.

Re: Dungeon raider (game demo)

Posted: Mon Apr 27, 2015 12:27 pm
by AndyLy
Bananenfreak
I tried, but
1. Shadows or not displayed or only some of them. (modulative)
2. If many objects, some of them turned at the wrong angle.
But anyway, in new version I made this possibility and added another option, hide objects, depending on the distance from the camera.

Re: Dungeon raider (game demo)

Posted: Mon Apr 27, 2015 5:19 pm
by applePi
DK_PETER , i will use one of the Comtois programs which produced a waving flag shape. but look when we use a sphere thinned slightly, it is automatically become a 2D flat surface which its vertices can move up/down if it is scaled like this something like this: ScaleEntity(0, 3, 0.5, 3) with the code inside UpdateMatrix(), but not like this ScaleEntity(0, 3, 0, 3) in the second case it will be flat but we can't move its vertices up/down. this needs more investigation or i miss something or the case will change if we use a costumed sphere. in any case i think the problem of a circular plane are solved
in the following something like a milk waving calmly inside a teacup
press 'W' to see the circular liquid mesh in wireframe and will see that it is really flat 2D

Code: Select all

Enumeration
  #mainwin = 10
  #mat
  #sphere
  #sphereMat
  #mirror
  
EndEnumeration

Structure Vector3
  x.f
  y.f
  z.f
EndStructure

Define.Vector3 Normal, v1, v2, v3

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

Define.f KeyX, KeyY, MouseX, MouseY

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

Declare UpdateMatrix()

If InitEngine3D()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  ExamineDesktops()
  OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "press W for wire frame, press S for Solid ,____ move by keyboard and mouse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-60, 0, 0, 0)   
   
   Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
    Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
    Add3DArchive(".", #PB_3DArchive_FileSystem)
    Parse3DScripts()
    
    CreateMaterial(6,LoadTexture(6,"ground_diffuse.png"))
    CreatePlane(3,1000,1000,50,50,10,10)
    CreateEntity(3,MeshID(3), MaterialID(6), 0,0,0)
    
       
  CreateMaterial(4, LoadTexture(4, "snow_1024.jpg"))
    
    
    ;-Camera
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,0,220,180, #PB_Absolute)
    CameraLookAt(0, 0, 90, 0)
    CameraBackColor(0, RGB(90, 0, 0))
    
    ;-Light
    CreateLight(0, RGB(255, 255, 255), 5, 15, 5)
    AmbientColor(RGB(255, 255, 255))
    CameraBackColor(0, RGB(0,100,100))
    
   
  CreateMesh(0, #PB_Mesh_TriangleList, #True)
  
  CreateSphere(0,20,30,30)

  
  CreateEntity(0, MeshID(0), MaterialID(4), 0,100,0)
  
  ScaleEntity(0, 3, 0.5, 3)
  
  GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0, 0)-1)
  ;GetMeshData(0,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(0, 0)-1)
  CreateMaterial(5,LoadTexture(5,"Geebee2.bmp"))
      MaterialCullingMode(5, #PB_Material_NoCulling )
      
      CreateCylinder(2,60,75, 16,0,0) ; the teacup
      CreateEntity(2,MeshID(2), MaterialID(5), 0,100,0 )
      
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardReleased(#PB_Key_W)
          MaterialShadingMode(4, #PB_Material_Wireframe)
        ElseIf KeyboardReleased(#PB_Key_S)
          MaterialShadingMode(4, #PB_Material_Solid)
          
        ElseIf KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
          ;Debug(MeshVertexCount(0, 0))
        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
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)
        MouseY = -(MouseDeltaY()/10)
      EndIf
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative) 
      
      ; Waves
      UpdateMatrix()
      AngleVague = AngleVague+WaveFrequency
      
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End


Procedure UpdateMatrix()
  Protected a, b, c, i, j
  Protected N.Vector3, V1.Vector3, V2.Vector3, V3.Vector3
  Protected.f magSq, oneOverMag
  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=Cos(dtime + (Sqr(Pow(0.5*xa,2)+Pow(0.5*zb,2))))*2
      
      c + 1 ; vertex number

    Next a
  Next b
  
  SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Normal, 0, MeshVertexCount(0, 0)-1)
EndProcedure

Re: Dungeon raider (game demo)

Posted: Mon Apr 27, 2015 9:09 pm
by DK_PETER
@applePi
Good example.
I believe that the problem is ScaleEntity(0, 3, 0, 3) using a sphere. You've 'flattened' the sphere completely.
Using ScaleEntity(0, 3, 0.1, 3) works fine too. The conclusion must be, that changing the 'y' position of vertices
on a completely flattened (sphere) on the 'y-height' (probably) can't be done.

Edit: Actually....It does change...The changes are very small - but they're there. Move REAL close and you can
see minute changes...(Unless my eyes are deceiving me). :-)