Page 1 of 1

PB 6.21 - ApplyEntityForce() Bug

Posted: Fri Mar 21, 2025 7:10 pm
by Mijikai
When pressing (and or holding) #PB_Key_Left or #PB_Key_Right while the spaceship is moving in one direction
it starts to behave out of control (as if it was really lagging) not sure how to describe it.

PB 6.21 x64 Linux Debian 12, on Windows 11 it worked fine.

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()