; Physics body settings example (an ArcBasic extension) ; A balloon that floats, a puck that stays flat, a fast bullet that ; doesn't miss the thin wall, and a crate that shows when it sleeps Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,5,-14 TurnEntity camera,15,0,0 light=CreateLight() RotateEntity light,50,30,0 ground=CreatePlane() EntityColor ground,70,90,70 EntityPhysics ground,1 ; gravity scale below 0 makes a body float upwards balloon=CreateSphere(12) PositionEntity balloon,-5,1,0 EntityColor balloon,255,80,80 EntityPhysics balloon,2,.1 EntityGravity balloon,-.2 EntityDamping balloon,.8,.8 ; the puck may only slide along X and Z and turn about its Y axis puck=CreateCylinder(16) ScaleEntity puck,.6,.15,.6 PositionEntity puck,0,.15,-2 EntityPhysics puck,2 EntityShape puck,4 EntityLockAxes puck,0,1,0,1,0,1 EntityFriction puck,0 ; a thin wall and a fast bullet with continuous collision detection wall=CreateCube() ScaleEntity wall,.05,2,2 PositionEntity wall,6,2,0 EntityPhysics wall,1 crate=CreateCube() ScaleEntity crate,.5,.5,.5 PositionEntity crate,2,4,2 EntityPhysics crate,2 While Not KeyHit(1) If KeyDown(203) Then ApplyForce puck,-8,0,0 If KeyDown(205) Then ApplyForce puck,8,0,0 If KeyDown(200) Then ApplyForce puck,0,0,8 If KeyDown(208) Then ApplyForce puck,0,0,-8 If KeyHit(57) bullet=CreateSphere(6) ScaleEntity bullet,.1,.1,.1 PositionEntity bullet,0,2,0 EntityPhysics bullet,2,.05 EntityGravity bullet,0 EntityCCD bullet SetEntityVelocity bullet,300,0,0 EndIf If KeyHit(17) Then WakeEntity crate : ApplyImpulse crate,0,4,0 UpdateWorld If EntitySleeping(crate) Then EntityColor crate,90,90,90 Else EntityColor crate,240,200,120 RenderWorld Text 0,0,"Arrows: slide the puck Space: fire at the wall W: wake the crate" Flip Wend End