; PhysicsShapeWind Example ; ------------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() Const PHYSICS_STATIC=0 Const PHYSICS_DYNAMIC=2 camera=CreateCamera() PositionEntity camera,0,3,-7 RotateEntity camera,20,0,0 light=CreateLight() RotateEntity light,45,-30,0 AmbientLight 60,60,60 ; An independent Box3D world with standard gravity world=CreatePhysicsWorld() ; Blue static floor ground=CreateCube() ScaleEntity ground,6,0.5,6 PositionEntity ground,0,-0.5,0 EntityColor ground,80,160,255 ground_body=CreatePhysicsBody(world,ground,PHYSICS_STATIC) ground_shape=PhysicsBodyBox(ground_body,12,1,12) ; An orange plank to push around plank=CreateCube() ScaleEntity plank,1.5,0.25,0.5 EntityColor plank,255,120,70 plank_body=CreatePhysicsBody(world,plank,PHYSICS_DYNAMIC) plank_shape=PhysicsBodyBox(plank_body,3,0.5,1) ResetPhysicsBody plank_body,0,1,0,0,0,0 While Not KeyDown(1) ; R puts the plank back in the middle If KeyHit(19) Then ResetPhysicsBody plank_body,0,1,0,0,0,0 ; Hold Space for an 8 m/s wind towards the camera; wind lasts one step If KeyDown(57) Then PhysicsShapeWind plank_shape,0,0,-8 StepPhysics world,1.0/60.0,4 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera R: reset Hold Space: wind Esc: exit" Text 0,20,"PhysicsShapeWind plank_shape,0,0,-8 while Space is held" Text 0,40,"The wind pushes on the plank's broad side, blowing it towards you" Flip Wend FreePhysicsWorld world End