It is currently Tue Mar 31, 2020 8:16 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Solitude - winter is coming
PostPosted: Sun Sep 24, 2017 6:55 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 843
Location: Denmark
Well, here's yet another small example.

Download the media file - if you wish to run the code below.
As usual...Unpack the zip to the same location as the code.

Solitude_media:
https://www.dropbox.com/s/ty09dl59aowxo ... a.zip?dl=0

Edit: Code split into two:

Code: PB 5.4X
Code:
;Soletude
;By DK_PETER
;Use WASD keys and mouse
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
DeclareModule _Cabin
  Declare.i Init()
  Declare.i Setup()
  Declare.i Run()
EndDeclareModule

Module _Cabin
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    #slash = "\"
  CompilerElse
    #slash = "/"
  CompilerEndIf
  Global  snd.i = #True
  Structure _Vars
    win.i
    scr.i
    ev.i
    quit.i
    cam.i
    lg.i
    sp.i
    th.i
    sn.i
  EndStructure
  Global v._Vars
 
  Structure _Object
    id.i
    ms.i
  EndStructure
 
  Structure _Special
    id.i
    ma.i
    tx.i
  EndStructure
 
  Structure _SpecialObj
    lg._Special
    candle._Special
    fire._Special
    smoke._Special
  EndStructure
  Global so._SpecialObj
 
  Structure _DefObj
    id.i
    ma.i
    ms.i
    tx.i
    eff._Special
  EndStructure
 
  Structure _Navigation
    x.f
    y.f
    z.f
    mx.f
    my.f
    speed.f
  EndStructure
  Global n._Navigation
 
  Structure _Content
    house._Object
    couch._Object
    candle._Object
    chair._Object
    door._Object
    ground._Object
    table._Object
    log._DefObj
    moon._DefObj
  EndStructure
  Global c._Content
 
  Global Path.s = GetPathPart(ProgramFilename())  ;<------------------Change if you want a different location
 
  Declare.i StatusUpdate()
  Declare.i CreateStarSky()
  Declare.f RandomF(min.f, Max.f)
 
  Procedure.f RandomF(min.f, Max.f)
    Protected SeedVal = Random(20000, 500)
    ProcedureReturn (Min + (Max - Min) * Random(SeedVal) / SeedVal)
  EndProcedure 
 
  Procedure.i Init()
    Protected returnvalue.i
    If InitEngine3D(#PB_Engine3D_DebugLog|#PB_Engine3D_AverageFPS) = 0
      ProcedureReturn #False
    EndIf
    If InitSprite() = 0
      ProcedureReturn #False
    EndIf
    If InitKeyboard() = 0
      ProcedureReturn #False
    EndIf
    If InitMouse() = 0
      ProcedureReturn #False
    EndIf
    If InitSound() = 0
      snd = #False
    EndIf
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i StatusUpdate()
    If IsSprite(v\sp) = 0 : v\sp = CreateSprite(#PB_Any, 300, 40) : TransparentSpriteColor(v\sp, 0) : EndIf
    StartDrawing(SpriteOutput(v\sp))
    Box(0, 0, 300, 40, 0)
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(0, 0, "Average fps: " + Str(Engine3DStatus(#PB_Engine3D_AverageFPS)), $F0B222)
    StopDrawing()
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i CreateStarSky()
    Protected x.i, col.i, alph, im = CreateImage(#PB_Any, 4096, 4096) ;Large texture - change if better
    StartDrawing(ImageOutput(im))
    DrawingMode(#PB_2DDrawing_AllChannels)
    For x = 0 To 20000
      col = Random(255, 120) : alph = Random(255, 70)
      Circle(Random(4095, 1), Random(4095, 1), Random(2,1), RGBA(col, col, col, alph))
    Next x
    StopDrawing()
    SaveImage(im, path + "texture" + #slash + "sky_UP.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_DN.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_RT.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_LF.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_BK.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_FR.jpg", #PB_ImagePlugin_JPEG, 10)
    SkyBox("sky.jpg")
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Setup()
    Protected x.i, rret.i
    ExamineDesktops()
    AntialiasingMode(#PB_AntialiasingMode_x6)
    v\win = OpenWindow(#PB_Any, 0, 0, DesktopWidth(0), DesktopHeight(0), "Solitude", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
    v\scr = OpenWindowedScreen(WindowID(v\win), 0, 0, DesktopWidth(0), DesktopHeight(0))
    Add3DArchive("texture", #PB_3DArchive_FileSystem)
    Add3DArchive("mesh", #PB_3DArchive_FileSystem)
    Add3DArchive("material", #PB_3DArchive_FileSystem)
    Add3DArchive("bitmap", #PB_3DArchive_FileSystem)
    Add3DArchive("script", #PB_3DArchive_FileSystem)
    Parse3DScripts()
    WorldShadows(#PB_Shadow_Modulative, 100)
    v\cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
    With c\ground
      \ms = LoadMesh(#PB_Any, "ground.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms), #PB_Material_None, 0, -2.8, 0, 1 << 1)
      ScaleEntity(\id, 40, 40, 40)
      CreateEntityBody(\id, #PB_Entity_StaticBody)
    EndWith
    With c\house
      \ms = LoadMesh(#PB_Any, "dkpeter_house.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 0.3, -150)
      ScaleEntity(\id, 1, 0.5, 1)
    EndWith
    With c\door ;Not correct door to the house...Fiddle with it to make it fit.. :-)
      \ms = LoadMesh(#PB_Any, "door.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, 130, 70, -120)
      ScaleEntity(\id, 1.2, 1, 0.5)
      RotateEntity(\id, 0, 90, -90)
    EndWith
    With c\table
      \ms = LoadMesh(#PB_Any, "table.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 0, -130)
      ScaleEntity(\id, 70, 70, 70)
    EndWith
    With c\chair
      \ms = LoadMesh(#PB_Any, "chair.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 50, -80)
      RotateEntity(\id, 0, -90, 0)
      ScaleEntity(\id, 70, 70, 70)
    EndWith
    With c\couch
      \ms = LoadMesh(#PB_Any, "couch.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -350, 0, 80)
      RotateEntity(\id, 0, -90, 0)
      ScaleEntity(\id, 3, 9, 3)
    EndWith
    With c\candle
      \ms = LoadMesh(#PB_Any, "candle.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 65, -130)
      ScaleEntity(\id, 9, 9, 9)
    EndWith
    With c\log
      \ms = CreateCylinder(#PB_Any, 7, 54)
      \tx = CreateTexture(#PB_Any, 20, 20)
      StartDrawing(TextureOutput(\tx))
      Box(0, 0, 20, 20, $234268)
      StopDrawing()
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -100, 14, -354)
      RotateEntity(\id, 0, 0, 90)
    EndWith
    so\lg\id = CreateLight(#PB_Any, $A8F3F6, -100, 30, -130)
    With so\candle
      \tx = CreateTexture(#PB_Any, 50, 50)
      StartDrawing(TextureOutput(\tx))
      DrawingMode(#PB_2DDrawing_Gradient)
      BackColor($3B78F6) : FrontColor($3BDCF6)
      EllipticalGradient(25, 30, 22, 30)
      Ellipse(25, 25, 20, 20)
      StopDrawing()
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      MaterialBlendingMode(\ma, #PB_Material_Add)
      \id = CreateParticleEmitter(#PB_Any, 0.1, 0.1, 0.1, #PB_Particle_Point, -100, 81, -130)
      ParticleMaterial(\id, MaterialID(\ma))
      ParticleSize(\id, 1.2, 3)
      ParticleEmissionRate(\id, 20)
      ParticleTimeToLive(\id, 0.1, 0.3)
      ParticleVelocity(\id, 0.1, 0.3)
      ParticleEmitterDirection(\id, 0, -1, 0)
    EndWith
    With c\moon
      \ms = CreateSphere(#PB_Any, 100)
      \tx = LoadTexture(#PB_Any, "moon.jpg")
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 800, 1800, 500)
      \eff\tx = CreateTexture(#PB_Any, 2048, 2048)
      StartDrawing(TextureOutput(\eff\tx))
      DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient)
      BackColor($FFFFFFFF) : FrontColor($00111111)
      CircularGradient(1024, 1024, 1000)
      GradientColor(0.1,$FFFFFFFF)
      Circle(1024, 1024, 1000)
      StopDrawing()
      \eff\ma = CreateMaterial(#PB_Any, TextureID(\eff\tx))
      MaterialBlendingMode(\eff\ma, #PB_Material_Add)
      \eff\id = CreateBillboardGroup(#PB_Any, MaterialID(\eff\ma), 300, 300)
      AddBillboard(\eff\id, 800, 1800, 500)
    EndWith
    so\smoke\id = GetScriptParticleEmitter(#PB_Any, "smokey")
    MoveParticleEmitter(so\smoke\id, -110, 271, -380)
    With so\fire
      \id = CreateParticleEmitter(#PB_Any, 90, 2, 30, #PB_Particle_Point, -100, 14, -350)
      \ma = CopyMaterial(so\candle\ma, #PB_Any)
      ParticleMaterial(\id, MaterialID(\ma))
      ParticleSize(\id, 3.2, 20)
      ParticleEmissionRate(\id, 1460)
      ParticleTimeToLive(\id, 0.1, 0.3)
      ParticleVelocity(\id, 0.2, 0.3)
      ParticleEmitterDirection(\id, 0, -1, 0)
      ret = CreateStarSky()
      If snd = #True
        v\sn = LoadSound(#PB_Any, Path + "snd" + #slash + "wind.wav")
        SoundVolume(v\sn, 70)
        PlaySound(v\sn, #PB_Sound_Loop)
      EndIf
    EndWith
  EndProcedure
 
  Procedure.i Run()
    n\speed = 1
    Repeat
      Repeat : v\ev = WindowEvent() : Until v\ev = 0
      ExamineMouse()
      n\mx = MouseDeltaX() * n\speed * 0.2
      n\my = MouseDeltaY() * n\speed * 0.2 
      ExamineKeyboard()
      If KeyboardPushed(#PB_Key_W) : n\z = -n\speed : ElseIf KeyboardPushed(#PB_Key_S) : n\z = n\speed  : Else : n\z = 0 : EndIf
      If KeyboardPushed(#PB_Key_A) : n\x = -n\speed : ElseIf KeyboardPushed(#PB_Key_D) : n\x = n\speed  : Else : n\x = 0 : EndIf
      MoveCamera(v\cam, n\x, 0 , n\z)
      If RayCollide(CameraX(v\cam), 125, CameraZ(v\cam), CameraX(v\cam), -15, CameraZ(v\cam)+1) = c\ground\id
        MoveCamera(v\cam, CameraX(v\cam), 115 + PickY() , CameraZ(v\cam), #PB_Absolute)
      EndIf
      RotateCamera(v\cam, -n\my, -n\mx, 0, #PB_Relative)
      RenderWorld()
      If KeyboardPushed(#PB_Key_Escape) : v\quit = #True : Delay(10) : EndIf
      ret = StatusUpdate()
      DisplayTransparentSprite(v\sp, 20, 0)
      FlipBuffers()
    Until v\quit = #True   
  EndProcedure
EndModule

If _Cabin::Init() = #True
  _Cabin::Setup()
  _Cabin::Run()
EndIf


For PB 5.5X And up

Code:
;Soletude
;By DK_PETER
;Use WASD keys and mouse
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
DeclareModule _Cabin
  Declare.i Init()
  Declare.i Setup()
  Declare.i Run()
EndDeclareModule

Module _Cabin
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    #slash = "\"
  CompilerElse
    #slash = "/"
  CompilerEndIf
  Global  snd.i = #True
  Structure _Vars
    win.i
    scr.i
    ev.i
    quit.i
    cam.i
    lg.i
    sp.i
    th.i
    sn.i
  EndStructure
  Global v._Vars
 
  Structure _Object
    id.i
    ms.i
  EndStructure
 
  Structure _Special
    id.i
    ma.i
    tx.i
  EndStructure
 
  Structure _SpecialObj
    lg._Special
    candle._Special
    fire._Special
    smoke._Special
  EndStructure
  Global so._SpecialObj
 
  Structure _DefObj
    id.i
    ma.i
    ms.i
    tx.i
    eff._Special
  EndStructure
 
  Structure _Navigation
    x.f
    y.f
    z.f
    mx.f
    my.f
    speed.f
  EndStructure
  Global n._Navigation
 
  Structure _Content
    house._Object
    couch._Object
    candle._Object
    chair._Object
    door._Object
    ground._Object
    table._Object
    log._DefObj
    moon._DefObj
  EndStructure
  Global c._Content
 
  Global Path.s = GetPathPart(ProgramFilename())  ;<------------------Change if you want a different location
 
  Declare.i StatusUpdate()
  Declare.i CreateStarSky()
  Declare.f RandomF(min.f, Max.f)
 
  Procedure.f RandomF(min.f, Max.f)
    Protected SeedVal = Random(20000, 500)
    ProcedureReturn (Min + (Max - Min) * Random(SeedVal) / SeedVal)
  EndProcedure 
 
  Procedure.i Init()
    Protected returnvalue.i
    If InitEngine3D(#PB_Engine3D_DebugLog|#PB_Engine3D_AverageFPS) = 0
      ProcedureReturn #False
    EndIf
    If InitSprite() = 0
      ProcedureReturn #False
    EndIf
    If InitKeyboard() = 0
      ProcedureReturn #False
    EndIf
    If InitMouse() = 0
      ProcedureReturn #False
    EndIf
    If InitSound() = 0
      snd = #False
    EndIf
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i StatusUpdate()
    If IsSprite(v\sp) = 0 : v\sp = CreateSprite(#PB_Any, 300, 40) : TransparentSpriteColor(v\sp, 0) : EndIf
    StartDrawing(SpriteOutput(v\sp))
    Box(0, 0, 300, 40, 0)
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(0, 0, "Average fps: " + Str(Engine3DStatus(#PB_Engine3D_AverageFPS)), $F0B222)
    StopDrawing()
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i CreateStarSky()
    Protected x.i, col.i, alph, im = CreateImage(#PB_Any, 4096, 4096) ;Large texture - change if better
    StartDrawing(ImageOutput(im))
    DrawingMode(#PB_2DDrawing_AllChannels)
    For x = 0 To 20000
      col = Random(255, 120) : alph = Random(255, 70)
      Circle(Random(4095, 1), Random(4095, 1), Random(2,1), RGBA(col, col, col, alph))
    Next x
    StopDrawing()
    SaveImage(im, path + "texture" + #slash + "sky_UP.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_DN.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_RT.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_LF.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_BK.jpg", #PB_ImagePlugin_JPEG, 10)
    SaveImage(im, path + "texture" + #slash + "sky_FR.jpg", #PB_ImagePlugin_JPEG, 10)
    SkyBox("sky.jpg")
    ProcedureReturn #True
  EndProcedure
 
  Procedure.i Setup()
    Protected x.i, rret.i
    ExamineDesktops()
    AntialiasingMode(#PB_AntialiasingMode_x6)
    v\win = OpenWindow(#PB_Any, 0, 0, DesktopWidth(0), DesktopHeight(0), "Solitude", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
    v\scr = OpenWindowedScreen(WindowID(v\win), 0, 0, DesktopWidth(0), DesktopHeight(0))
    Add3DArchive("texture", #PB_3DArchive_FileSystem)
    Add3DArchive("mesh", #PB_3DArchive_FileSystem)
    Add3DArchive("material", #PB_3DArchive_FileSystem)
    Add3DArchive("bitmap", #PB_3DArchive_FileSystem)
    Add3DArchive("script", #PB_3DArchive_FileSystem)
    Parse3DScripts()
    WorldShadows(#PB_Shadow_Modulative, 100)
    v\cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
    With c\ground
      \ms = LoadMesh(#PB_Any, "ground.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms), #PB_Material_None, 0, -2.8, 0, 1 << 1)
      ScaleEntity(\id, 40, 40, 40)
      CreateEntityBody(\id, #PB_Entity_StaticBody)
    EndWith
    With c\house
      \ms = LoadMesh(#PB_Any, "dkpeter_house.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 0.3, -150)
      ScaleEntity(\id, 1, 0.5, 1)
    EndWith
    With c\door ;Not correct door to the house...Fiddle with it to make it fit.. :-)
      \ms = LoadMesh(#PB_Any, "door.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, 130, 70, -120)
      ScaleEntity(\id, 1.2, 1, 0.5)
      RotateEntity(\id, 0, 90, -90)
    EndWith
    With c\table
      \ms = LoadMesh(#PB_Any, "table.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 0, -130)
      ScaleEntity(\id, 70, 70, 70)
    EndWith
    With c\chair
      \ms = LoadMesh(#PB_Any, "chair.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 50, -80)
      RotateEntity(\id, 0, -90, 0)
      ScaleEntity(\id, 70, 70, 70)
    EndWith
    With c\couch
      \ms = LoadMesh(#PB_Any, "couch.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -350, 0, 80)
      RotateEntity(\id, 0, -90, 0)
      ScaleEntity(\id, 3, 9, 3)
    EndWith
    With c\candle
      \ms = LoadMesh(#PB_Any, "candle.mesh")
      \id = CreateEntity(#PB_Any, MeshID(\ms),#PB_Material_None, -100, 65, -130)
      ScaleEntity(\id, 9, 9, 9)
    EndWith
    With c\log
      \ms = CreateCylinder(#PB_Any, 7, 54)
      CompilerIf #PB_Compiler_Version < 550
        \tx = CreateTexture(#PB_Any, 20, 20)
      CompilerElse
        \tx = CreateTexture(#PB_Any, 20, 20, "log")
      CompilerEndIf
      StartDrawing(TextureOutput(\tx))
      Box(0, 0, 20, 20, $234268)
      StopDrawing()
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -100, 14, -354)
      RotateEntity(\id, 0, 0, 90)
    EndWith
    so\lg\id = CreateLight(#PB_Any, $A8F3F6, -100, 30, -130)
    With so\candle
      \tx = CreateTexture(#PB_Any, 50, 50, "flame")
      StartDrawing(TextureOutput(\tx))
      DrawingMode(#PB_2DDrawing_Gradient)
      BackColor($3B78F6) : FrontColor($3BDCF6)
      EllipticalGradient(25, 30, 22, 30)
      Ellipse(25, 25, 20, 20)
      StopDrawing()
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      MaterialBlendingMode(\ma, #PB_Material_Add)
      \id = CreateParticleEmitter(#PB_Any, 0.1, 0.1, 0.1, #PB_Particle_Point,-100, 81, -130)
      ParticleMaterial(\id, MaterialID(\ma))
      ParticleSize(\id, 1.2, 3)
      ParticleEmissionRate(\id, 20)
      ParticleTimeToLive(\id, 0.1, 0.3)
      ParticleVelocity(\id, #PB_Particle_MinimumVelocity, 0.1)
      ParticleVelocity(\id, #PB_Particle_Velocity, 0.2)
      ParticleVelocity(\id, #PB_Particle_MaximumVelocity, 0.3)
      ParticleEmitterDirection(\id, 0, 1, 0)
    EndWith
    With c\moon
      \ms = CreateSphere(#PB_Any, 100)
      \tx = LoadTexture(#PB_Any, "moon.jpg")
      \ma = CreateMaterial(#PB_Any, TextureID(\tx))
      \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 800, 1800, 500)
      \eff\tx = CreateTexture(#PB_Any, 2048, 2048, "glare")
      StartDrawing(TextureOutput(\eff\tx))
      DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient)
      BackColor($FFFFFFFF) : FrontColor($00111111)
      CircularGradient(1024, 1024, 1000)
      GradientColor(0.1,$FFFFFFFF)
      Circle(1024, 1024, 1000)
      StopDrawing()
      \eff\ma = CreateMaterial(#PB_Any, TextureID(\eff\tx))
      MaterialBlendingMode(\eff\ma, #PB_Material_Add)
      \eff\id = CreateBillboardGroup(#PB_Any, MaterialID(\eff\ma), 300, 300)
      AddBillboard(\eff\id, 800, 1800, 500)
    EndWith
    so\smoke\id = GetScriptParticleEmitter(#PB_Any, "smokey")
    MoveParticleEmitter(so\smoke\id, -110, 271, -380)
    With so\fire
      \id = CreateParticleEmitter(#PB_Any, 90, 2, 30, #PB_Particle_Point, -100, 14, -350)
      \ma = CopyMaterial(so\candle\ma, #PB_Any)
      ParticleMaterial(\id, MaterialID(\ma))
      ParticleSize(\id, 3.2, 20)
      ParticleEmissionRate(\id, 1460)
      ParticleTimeToLive(\id, 0.2, 0.3)
      ParticleVelocity(\id, #PB_Particle_MinimumVelocity, 0.1)
      ParticleVelocity(\id, #PB_Particle_Velocity, 0.2)
      ParticleVelocity(\id, #PB_Particle_MaximumVelocity, 0.3)
      ParticleEmitterDirection(\id, 0, 1, 0)
      ret = CreateStarSky()
      If snd = #True
        v\sn = LoadSound(#PB_Any, Path + "snd" + #slash + "wind.wav")
        SoundVolume(v\sn, 70)
        PlaySound(v\sn, #PB_Sound_Loop)
      EndIf
    EndWith
  EndProcedure
 
  Procedure.i Run()
    n\speed = 1
    Repeat
      Repeat : v\ev = WindowEvent() : Until v\ev = 0
      ExamineMouse()
      n\mx = MouseDeltaX() * n\speed * 0.2
      n\my = MouseDeltaY() * n\speed * 0.2 
      ExamineKeyboard()
      If KeyboardPushed(#PB_Key_W) : n\z = -n\speed : ElseIf KeyboardPushed(#PB_Key_S) : n\z = n\speed  : Else : n\z = 0 : EndIf
      If KeyboardPushed(#PB_Key_A) : n\x = -n\speed : ElseIf KeyboardPushed(#PB_Key_D) : n\x = n\speed  : Else : n\x = 0 : EndIf
      MoveCamera(v\cam, n\x, 0 , n\z)
      If RayCollide(CameraX(v\cam), 125, CameraZ(v\cam), CameraX(v\cam), -15, CameraZ(v\cam)+1) = c\ground\id
        MoveCamera(v\cam, CameraX(v\cam), 115 + PickY() , CameraZ(v\cam), #PB_Absolute)
      EndIf
      RotateCamera(v\cam, -n\my, -n\mx, 0, #PB_Relative)
      RenderWorld()
      If KeyboardPushed(#PB_Key_Escape) : v\quit = #True : Delay(10) : EndIf
      ret = StatusUpdate()
      DisplayTransparentSprite(v\sp, 20, 0)
      FlipBuffers()
    Until v\quit = #True   
  EndProcedure
EndModule

If _Cabin::Init() = #True
  _Cabin::Setup()
  _Cabin::Run()
EndIf

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Solitude - winter is coming
PostPosted: Wed Sep 27, 2017 5:46 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4658
Location: Lyon - France
Waouuuh very nice !!! it works very well :D
I hope a day have my house like them :lol:
Thanks for sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye