; Physics characters example (an ArcBasic extension) ; A character that walks, jumps, climbs steps and slopes and pushes crates. ; Arrows: walk and turn Space: jump P: push harder Graphics3D 640,480 SetBuffer BackBuffer() light=CreateLight() RotateEntity light,50,30,0 ground=CreatePlane() EntityColor ground,70,90,70 EntityPhysics ground,1 ; stairs: each step a quarter of a unit higher than the last For i=1 To 4 s=CreateCube() ScaleEntity s,1.5,i*.125,1 PositionEntity s,-5,i*.125,3+i*2 EntityColor s,150,150,170 EntityPhysics s,1 Next ; a gentle ramp and one too steep to walk up ramp=CreateCube() ScaleEntity ramp,1.5,.1,4 PositionEntity ramp,0,1.2,6 RotateEntity ramp,-20,0,0 EntityColor ramp,170,140,100 EntityPhysics ramp,1 steep=CreateCube() ScaleEntity steep,1.5,.1,3 PositionEntity steep,5,1.4,5 RotateEntity steep,-60,0,0 EntityColor steep,200,90,80 EntityPhysics steep,1 ; crates to push about For i=0 To 5 c=CreateCube() ScaleEntity c,.4,.4,.4 PositionEntity c,-3+i*1.2,.4,-4 EntityColor c,200,160,90 EntityPhysics c,2,.5 Next ; the hero: a pivot at its feet carrying a body and a nose that shows which way it faces hero=CreatePivot() body=CreateCylinder(16,True,hero) ScaleEntity body,.4,.9,.4 PositionEntity body,0,.9,0 EntityColor body,90,160,255 nose=CreateCube(hero) ScaleEntity nose,.12,.12,.25 PositionEntity nose,0,1.5,.45 EntityCharacter hero,.4,1.8,.3,45 camera=CreateCamera(hero) PositionEntity camera,0,4,-8 TurnEntity camera,20,0,0 push#=1 While Not KeyHit(1) If KeyDown(203) Then TurnEntity hero,0,3,0 If KeyDown(205) Then TurnEntity hero,0,-3,0 speed#=0 If KeyDown(200) Then speed=4 If KeyDown(208) Then speed=-2 CharacterWalk hero,0,speed If KeyHit(57) Then CharacterJump hero,6 If KeyHit(25) Then push=4-push : CharacterPush hero,push UpdateWorld RenderWorld Text 0,0,"Arrows: walk and turn Space: jump P: push harder" If CharacterOnFloor(hero) Then floor$="on the floor" Else floor$="in the air" Text 0,15,"The hero is "+floor$+" push strength "+push Flip Wend End