Outils pour utilisateurs

Outils du site


playground:musicspacial

14-MusicSpacial.sb

Voir

14-MusicSpacial.sb
;Babylon.sbi - Music Spatial
 
EnableExplicit
 
IncludeFile "babylon/babylon.sbi"
UseModule BJS
 
Global Scene, Camera, Light, Sound1, Sound2, Ground, GroundTex, GroundMat, Pole1, Pole2
 
Declare LoadGame()
Declare RenderGame()
 
InitEngine(@LoadGame())
 
Procedure LoadGame()    
  Scene = CreateScene()
  If Scene
 
    ;Load Music
    MusicLoad("Loop", "data/sounds/loop.mp3", #True, #True)
    Sound1 = MusicLoad("Sound1", "data/sounds/calm.wav", #True, #True)
    Sound2 = MusicLoad("Sound2", "data/sounds/ambience.wav", #True, #True)
 
    ;Camera
    Camera = CreateCamera("camera", 0, 40, 20, #BJS_Free)
    CameraBodySize(Camera, 2, 20, 2)
    CameraLookAt(Camera, 0, 10, 1000)
    ClearScene(RGB(0, 0, 0))
    Light = CreateLight("Light", 0, 100, 0, 1, #BJS_Point)
 
    ;Ground
    Ground = CreateGround("Ground", 5000, 5000, 4)
    GroundTex = LoadTexture("Ground", "data/textures/Beton1.png")
    GroundMat = CreateMaterial("Ground")
    SetMaterialTexture(GroundMat, #BJS_Diffuse, GroundTex)
    ScaleMaterial(GroundMat, 40, 40)
    SetMeshMaterial(Ground, GroundMat)    
 
    ;Music Pole
    Pole1 = CreateSphere("Sound1", 10)
    MoveMesh(Pole1, -100, 30, 200)
    MusicAttachToMesh(Pole1, Sound1)
 
    Pole2 = CreateSphere("Sound2", 10)
    MoveMesh(Pole2, 100, 30, 200)
    MusicAttachToMesh(Pole2, Sound2)
 
    RenderLoop(@RenderGame())
  EndIf
EndProcedure
 
Procedure RenderGame()     
  RenderWorld() 
EndProcedure
playground/musicspacial.txt · Dernière modification: 2018/01/11 02:03 de falsam