Trying some 3D and I have some problems with entitycollide and jumping.
Without entitycollide the cube moves as it should and with entitycollide it lags.
When i try easy jumping it jumps but when I move the cube in any direction then falling slows down.
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
winID = OpenWindow(#PB_Any, 0, 0, 1366, 768, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(winID), 0, 0, 1266, 768)
WorldShadows(#PB_Shadow_Modulative)
EnableWorldPhysics(1)
EnableWorldCollisions(1)
WorldGravity(-9.8)
WorldDebug(#PB_World_DebugBody)
CreateCamera(1,0,0,100,100)
CreateLight(1,#White)
MoveLight(1,-100,100,-20)
CreateCube(1,1)
CreateEntity(1,MeshID(1),#PB_Material_None)
MoveEntity(1,0,0,-5)
CreatePlane(1,1000,1000,100,100,100,100)
CreateEntity(0,MeshID(1),#PB_Material_None)
MoveEntity(0,0,-1,0)
CreateEntityBody(0,#PB_Entity_StaticBody)
CreateEntityBody(1,#PB_Entity_BoxBody,1,0,0.3)
EntityAngularFactor(1,0,1,0)
Repeat
ExamineMouse()
ExamineKeyboard()
mx = MouseDeltaX()
If mx
RotateEntity(1,0,mx/4,0,#PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_Space) And jumping = 0
jumping = 1
EntityVelocity(1,0,4,0)
EndIf
; res = EntityCollide(0, 1) ; <-- uncomment this
If res > 0
jumping = 0
EndIf
If KeyboardPushed(#PB_Key_W)
MoveEntity(1,-0.5,0,0,#PB_Local)
EndIf
If KeyboardPushed(#PB_Key_S)
MoveEntity(1,0.5,0,0,#PB_Local)
EndIf
RenderWorld()
event = WindowEvent()
FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End