Using the space key you can apply a force to the cube in the Z direction
Here, when the cube stopped bouncing on the ground, using the space key dosent have any effect
It's like the physic engine had frozen
What am i doing wrong ?
Code: Select all
EnableExplicit
InitEngine3D()
InitSprite()
EnableWorldPhysics(1)
EnableWorldCollisions(1)
InitKeyboard()
Enumeration
#window1
#camera
#light
#ground
#ground_e
#cube
#cube_e
#mat_cube
#tex_cube
#mat_gnd
#tex_gnd
EndEnumeration
Global cubes
Procedure exit()
End
EndProcedure
Procedure scan()
Define ev=WindowEvent()
Select ev
Case #PB_Event_CloseWindow
exit()
EndSelect
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
exit()
EndIf
If KeyboardPushed(#PB_Key_Space)
ApplyEntityForce(#cube_e,0,0,2)
EndIf
EndProcedure
Procedure render()
RenderWorld()
FlipBuffers()
EndProcedure
Procedure create_world()
CreateTexture(#tex_cube,64,64)
StartDrawing(TextureOutput(#tex_cube))
FillArea(1,1,-1,$e354e5)
StopDrawing()
CreateTexture(#tex_gnd,64,64)
StartDrawing(TextureOutput(#tex_gnd))
FillArea(1,1,-1,$788e52)
StopDrawing()
CreateMaterial(#mat_cube,TextureID(#tex_cube))
CreateMaterial(#mat_gnd,TextureID(#tex_gnd))
CreateCube(#cube,1)
CreateEntity(#cube_e,MeshID(#cube),MaterialID(#mat_cube),0,5,0)
EntityPhysicBody(#cube_e,#PB_Entity_BoxBody,1,0.8,0.5)
CreatePlane(#ground,100,100,1,1,1,1)
CreateEntity(#ground_e,MeshID(#ground),MaterialID(#mat_gnd))
EntityPhysicBody(#ground_e,#PB_Entity_StaticBody,1,0.5,0.1)
CreateCamera(#camera,0,0,1024,768)
CameraLocate(#camera,0,5,-10)
CameraLookAt(#camera,0,0,0)
CreateLight(#light,RGB(255,255,255),0,20,-5)
EndProcedure
If OpenWindow(#window1,0,0,1024,768,"Physic test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(#window1),0,0,1024,768,0,0,0)
WorldShadows(#PB_Shadow_Modulative)
create_world()
Repeat
scan()
render()
ForEver
EndIf
EndIf

