; Physics forces example (an ArcBasic extension) ; Arrows push the ball, Space makes it jump, T gives it a twist Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,10,-14 TurnEntity camera,35,0,0 light=CreateLight() RotateEntity light,50,30,0 ground=CreatePlane() EntityColor ground,90,90,130 EntityPhysics ground,1 ball=CreateSphere(16) PositionEntity ball,0,1,0 EntityColor ball,255,200,60 EntityPhysics ball,2,1 box=CreateCube() PositionEntity box,4,1,2 EntityPhysics box,2,2 While Not KeyHit(1) ; forces push steadily while the keys are held If KeyDown(203) Then ApplyForce ball,-15,0,0 If KeyDown(205) Then ApplyForce ball,15,0,0 If KeyDown(200) Then ApplyForce ball,0,0,15 If KeyDown(208) Then ApplyForce ball,0,0,-15 ; impulses act at once If KeyHit(57) And EntityY(ball)<1.1 Then ApplyImpulse ball,0,6,0 If KeyHit(20) Then ApplyTorqueImpulse box,0,8,0 : ApplyImpulse box,0,10,0 If KeyHit(31) Then SetEntityVelocity ball,0,0,0 : SetEntitySpin ball,0,0,0 If KeyDown(25) Then ApplyTorque box,0,0,20 UpdateWorld RenderWorld Text 0,0,"Arrows: push Space: jump T: flip the box P: roll the box S: stop the ball" speed#=Sqr(EntityVelocityX(ball)^2+EntityVelocityY(ball)^2+EntityVelocityZ(ball)^2) Text 0,15,"Ball speed: "+speed+" units a second" Text 0,30,"Box spin: "+EntitySpinPitch(box)+", "+EntitySpinYaw(box)+", "+EntitySpinRoll(box) Flip Wend End