ArcBasicDocs

help/commands/3d_examples

SetEntityVelocity.abs

47 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.

Download SetEntityVelocity.absAll files in this folder

SetEntityVelocity.abs
; Physics forces example (an ArcBasic extension); Arrows push the ball, Space makes it jump, T gives it a twistGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,10,-14TurnEntity camera,35,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,90,90,130EntityPhysics ground,1ball=CreateSphere(16)PositionEntity ball,0,1,0EntityColor ball,255,200,60EntityPhysics ball,2,1box=CreateCube()PositionEntity box,4,1,2EntityPhysics box,2,2While 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)	FlipWendEnd