For the moment I would like Sinbad to stop sliding on the floor:)
Code: Select all
EnableExplicit
Global window, ww, wh, event, camera, Material, Mesh, Entity, Sound, Node
Global Player, PlayerSpeed, CurrentAnimation.s
CompilerIf Subsystem("OpenGL") = #False
MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
End
CompilerEndIf
InitEngine3D(#PB_Engine3D_DebugLog)
InitKeyboard()
InitSprite()
; Window & Screen 3D
window = OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_BorderLess | #PB_Window_Maximize)
ww = WindowWidth (window, #PB_Window_InnerCoordinate)
wh = WindowHeight(window, #PB_Window_InnerCoordinate)
OpenWindowedScreen(WindowID(window), 0, 0, ww, wh)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\Packs\Sinbad.zip", #PB_3DArchive_Zip)
Parse3DScripts()
; Light
CreateLight(#PB_Any,RGB(255, 218, 185), 500, 1000, 1000)
WorldShadows(#PB_Shadow_Additive)
; Camera
camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(camera, 0, 400, 3000)
CameraLookAt(camera, 0, 0, 0)
; Entity
Mesh = CreatePlane(#PB_Any, 5000, 5000, 50, 50, 5, 5)
Material = CreateMaterial(#PB_Any, TextureID(LoadTexture(#PB_Any, "MRAMOR6X6.jpg")))
Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material))
CreateEntityBody(Entity, #PB_Entity_StaticBody, 1, 0, 100)
Mesh = CreateCube(#PB_Any, 200)
Material = CreateMaterial(#PB_Any, TextureID(LoadTexture(#PB_Any, "Caisse.png")))
Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), -1000, 100, 0)
CreateEntityBody(Entity, #PB_Entity_StaticBody, 1, 0, 1)
Entity = CopyEntity(Entity, -1)
MoveEntity(Entity, 1000, 100, 0)
Mesh = LoadMesh(#PB_Any, "sinbad.mesh")
Player = CreateEntity(-1, MeshID(Mesh), #PB_Material_None, 0, 125, 2000)
ScaleEntity(Player, 25, 25, 25)
CreateEntityBody(Player, #PB_Entity_ConvexHullBody, 200, 1, 100)
EntityAngularFactor(Player, 0, 1, 0)
RotateEntity(Player, 0, 180, 0)
; Sound
Sound = LoadSound3D(#PB_Any, "Siren.ogg")
Node = CreateNode(#PB_Any, -1000, 100, 0)
AttachNodeObject(Node, SoundID3D(Sound))
SoundRange3D(Sound, 300, 1000)
PlaySound3D(Sound, #PB_Sound3D_Loop)
Sound = LoadSound3D(#PB_Any, "Roar.ogg")
Node = CreateNode(#PB_Any, 1000, 100, 0)
AttachNodeObject(Node, SoundID3D(Sound))
SoundRange3D(Sound, 300, 1000)
PlaySound3D(Sound, #PB_Sound3D_Loop)
; Render
While #True
event = WindowEvent()
ExamineKeyboard()
If event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Break
EndIf
If KeyboardPushed (#PB_Key_Up)
PlayerSpeed = 300
CurrentAnimation = "RunBase"
ElseIf KeyboardPushed (#PB_Key_Down)
PlayerSpeed = -300
CurrentAnimation = "RunBase"
Else
CurrentAnimation = "IdleTop"
PlayerSpeed = 0
EndIf
If KeyboardPushed (#PB_Key_Left)
RotateEntity(Player, 0, 3, 0, #PB_Relative)
CurrentAnimation = "RunBase"
ElseIf KeyboardPushed (#PB_Key_Right)
RotateEntity(Player, 0, -3, 0, #PB_Relative)
CurrentAnimation = "RunBase"
EndIf
If PlayerSpeed
DisableEntityBody(Player, #False) ; Wake up entity (BugWare)
MoveEntity(Player, 0, 0, PlayerSpeed, #PB_Absolute|#PB_Local)
EndIf
;Play animation
If EntityAnimationStatus(Player, CurrentAnimation) = #PB_EntityAnimation_Stopped
StartEntityAnimation(Player, CurrentAnimation)
EndIf
CameraFollow(Camera, EntityID(Player), 180, EntityY(Player) + 100, 250, 0.5, 0.5, #True)
SoundListenerLocate(CameraX(Camera), CameraY(Camera), CameraZ(Camera))
RenderWorld()
FlipBuffers()
Wend