it starts to behave out of control (as if it was really lagging) not sure how to describe it.
PB 6.30 x64 Linux Debian 12, not tested on Windows / Mac.
Code:
Code: Select all
EnableExplicit
Procedure.i Main()
Protected.i exit
Protected.i camera,light
Protected.i mesh_ship,mat_ship,obj_ship
If InitEngine3D() And InitSprite() And InitKeyboard()
If OpenWindow(0,0,0,800,800,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0))
SetFrameRate(60)
;------------------------------------------------------ enable physics
EnableWorldPhysics(#True)
WorldGravity(0)
;------------------------------------------------------ create camera
camera = CreateCamera(#PB_Any,0,0,100,100)
MoveCamera(camera,0,0,100,#PB_Absolute)
CameraLookAt(camera,0,0,0)
;------------------------------------------------------ create lighting
light = CreateLight(#PB_Any,#White,0,0,100)
;------------------------------------------------------ create space ship
mesh_ship = CreateCone(#PB_Any,1,3,6,1)
mat_ship = CreateMaterial(#PB_Any,#Null,#Red)
obj_ship = CreateEntity(#PB_Any,MeshID(mesh_ship),MaterialID(mat_ship))
CreateEntityBody(obj_ship,#PB_Entity_ConeBody)
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_None
Break
Case #PB_Event_CloseWindow
exit = #True
EndSelect
ForEver
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
ApplyEntityForce(obj_ship,0,20,0,0,0,0,#PB_Local,#PB_Local)
EndIf
If KeyboardPushed(#PB_Key_Left)
RotateEntity(obj_ship,0,0,4,#PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_Right)
RotateEntity(obj_ship,0,0,-4,#PB_Relative)
EndIf
RenderWorld()
FlipBuffers()
Until exit Or KeyboardPushed(#PB_Key_Escape)
CloseScreen()
EndIf
CloseWindow(0)
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
