Code : Tout sélectionner
EnableExplicit
;Scene
Global Camera, Light
; Returns a random sign {-1, 1}
Macro RandomSign()
( Random(1)*2-1 )
EndMacro
;Summary
Declare GameLoad()
Declare RenderGame3D()
Declare RenderGame2D()
Declare Exit()
GameLoad()
Procedure GameLoad()
Protected Window, n
If InitEngine3D() And InitKeyboard() And InitSprite() And InitMouse() And InitSound()
Window = OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_Maximize | #PB_Window_BorderLess)
SetWindowColor(Window, 0)
;-[Screen]
OpenWindowedScreen(WindowID(Window),0, 0, WindowWidth(Window) , WindowHeight(Window))
KeyboardMode(#PB_Keyboard_International)
;-[2D]
;-[3D]
Add3DArchive(#PB_Compiler_Home + "Examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
;-Camera
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
CameraBackColor(Camera, RGB(0, 0, 0))
MoveCamera(Camera, 0, 0, -100)
CameraLookAt(Camera, 0, 0, 0)
;-Light
Light = CreateLight(#PB_Any, RGB(255, 255, 255), 0, 1000, 0, #PB_Light_Point)
SetLightColor(Light, #PB_Light_SpecularColor, RGB(255, 255, 255))
SetLightColor(Light, #PB_Light_DiffuseColor, RGB(255, 255, 255))
;Création de 5000 cubes
CreateMaterial(0, TextureID(LoadTexture(-1, "glass_Dirt.png")))
MaterialBlendingMode(0, #PB_Material_AlphaBlend)
SetMaterialColor(0, #PB_Material_SpecularColor, RGB(255,255,255))
CreateEntity(0, MeshID(CreateCube(-1, 8)), MaterialID(0))
For n = 1 To 5000
MoveEntity(CopyEntity(0, -1), Random(1000) * RandomSign(), Random(1000) * RandomSign(), Random(1000) * RandomSign())
Next
;-Loop
While #True
Repeat : Until WindowEvent() = 0
FlipBuffers()
RenderGame3D()
RenderWorld()
RenderGame2D()
Wend
Else
EndIf
EndProcedure
Procedure RenderGame3D()
RotateCamera(Camera, 0.1, 0.1, 0.1, #PB_Relative)
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Exit()
EndIf
EndIf
If ExamineMouse()
EndIf
EndProcedure
Procedure RenderGame2D()
EndProcedure
Procedure Exit()
End
EndProcedure