; Joint motors, limits and springs example (an ArcBasic extension) ; A windmill turned by a motor, a lift that goes up and down between its ; limits, and a springy platform. Up/Down change the windmill's speed Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,5,-16 TurnEntity camera,10,0,0 light=CreateLight() RotateEntity light,50,30,0 ground=CreatePlane() EntityColor ground,80,80,110 EntityPhysics ground,1 ; the windmill: sails on a hinge facing the camera, driven by a motor tower=CreateCube() : ScaleEntity tower,.3,3,.3 : PositionEntity tower,-5,3,1 : EntityPhysics tower,1 sails=CreatePivot() PositionEntity sails,-5,6,0 For i=0 To 3 blade=CreateCube(sails) ScaleEntity blade,.25,1.6,.05 TurnEntity blade,0,0,i*90 MoveEntity blade,0,1.6,0 EntityColor blade,240,240,250 Next EntityPhysics sails,2,2 mill=HingeJoint(sails,0,-5,6,0,0,0,1) speed#=60 JointMotor mill,speed,400 ; the lift: a platform on a slider that moves between 0 and 4 units up lift=CreateCube() : ScaleEntity lift,1.2,.1,1.2 : PositionEntity lift,1,.2,0 EntityColor lift,255,180,60 EntityPhysics lift,2,5 shaft=SliderJoint(lift,0,0,1,0) JointLimits shaft,0,4 JointMotor shaft,1.5,400 crate=CreateCube() : ScaleEntity crate,.4,.4,.4 : PositionEntity crate,1,.8,0 : EntityPhysics crate,2 ; a springy platform: drop crates on it with Space pad=CreateCube() : ScaleEntity pad,1.2,.1,1.2 : PositionEntity pad,6,2,0 EntityColor pad,90,220,140 EntityPhysics pad,2,2 bounce=SliderJoint(pad,0,0,1,0) JointSpring bounce,150,2 While Not KeyHit(1) If KeyDown(200) Then speed=speed+2 : JointMotor mill,speed,400 If KeyDown(208) Then speed=speed-2 : JointMotor mill,speed,400 ; turn the lift round at the ends of its travel If JointPosition(shaft)>3.95 Then JointMotor shaft,-1.5,400 If JointPosition(shaft)<.05 Then JointMotor shaft,1.5,400 If KeyHit(57) c=CreateCube() : ScaleEntity c,.3,.3,.3 : PositionEntity c,6+Rnd(-.5,.5),6,Rnd(-.3,.3) EntityPhysics c,2 EndIf UpdateWorld RenderWorld Text 0,0,"Up/Down: windmill speed "+Int(speed)+" degrees a second Space: drop a crate on the spring" Text 0,15,"Sails at "+Int(JointPosition(mill))+" degrees, lift at "+JointPosition(shaft) Flip Wend End