Sync On:Sync Rate 60:Autocam Off:Global n#:Global cFlag as Integer:Global LimbMatrix As Integer:Global EyeVector As Integer:Global LookAtVector As Integer:Global LookUpVector As Integer:Global DropDown as Integer:Global dd as Integer:Global tx#:Global ty#:Global tz#:Global MaxArry as Integer:Global Score as Integer:Dim KickFlag(1) as Float:Dim Kick(5):Dim cFlag(0) as Integer:Dim n(0) as Float Dim PreLimb(0):LimbMatrix=6:EyeVector=3:LookAtVector=4:LookUpVector=5:For i = 1 to 6: r=Make Vector3(i):Next i:r = Make Matrix4( LimbMatrix ):Make Object Sphere 1,6,8,8:Prepare_Limb(1,0,2):Delete Object 1:Make Object Sphere 1,6,15,15:Set Object Collision To Spheres 1:Make Object Box 2,100,5,120:Make Object Box 3,20,11,5:Offset Limb 3,0,8,0,0:Make Mesh From Object 3,3:Delete Object 3:Add Limb 2,1,3 Prepare_Limb(2,1,.001):Offset Limb 2,1,-20,2.6,-50:Rotate Limb 2,1,0,30,0:Color Limb 2,1,Rgb(50,50,100):Add Limb 2,2,3:Prepare_Limb(2,2,.001):Offset Limb 2,2,20,2.6,-50:Rotate Limb 2,2,0,-210,0:Color Limb 2,2,Rgb(50,50,100):Add_Limb(2,7,10,120,-50,3,0,0,0,0):Add_Limb(2,7,10,120,50,3,0,0,0,0):Add_Limb(2,100,10,7,0,3,60,0,0,0):Add_Limb(2,4,6,4,0,3,30,0,42,0):Add_Limb(2,4,6,4,-9,3,20,0,45,0):Add_Limb(2,4,6,4,9,3,20,0,48,0):Add_Limb(2,18,8,4,-30,3,-45,0,20,0):Add_Limb(2,18,8,4,30,3,-45,0,-200,0):Add_Limb(2,6,6,6,-47,3,-30,0,45,0):Add_Limb(2,6,6,6,47,3,-30,0,45,0):rr=Add_Limb(2,2,8,7,20,3,35,0,0,0) Add_Limb(2,2,8,7,29,3,34,0,0,0):Add_Limb(2,2,8,7,38,3,33,0,0,0):Add_Limb(2,21,8,3,-31,3,-27,0,40,0):Add_Limb(2,21,8,3,31,3,-27,0,-220,0):dd=Add_Limb(2,20,8,4,-30,2.4,53,0,0,0):Add_Limb(2,5,7,5,-36,3,-41,0,20,0):Add_Limb(2,5,7,5,36,3,-41,0,-200,0):l=Add_Limb(2,100,.1,120,0,8.5,0,0,0,0):Hide Limb 2,l:Color Limb 2,0,RGB(100,100,254):Set Object Collision Off 2:Position Camera 0,70,-80:Point Camera 0,0,0:Make Object Sphere 3,9:Scale Object 3,100,40,100:Make Mesh From Object 3,3:Delete Object 3:Pitch Object Up 2,3:For i = 0 to 2:Make Object 11+i,3,0 Position Object 11+i,Limb Position X(2,6+i),Limb Position Y(2,6+i)+2.0,Limb Position Z(2,6+i):Set Object Collision To Spheres 11+i:Color Object 11+i,Rgb(255,0,0):Next i:Make Object Box 14,17,7,1:Position Object 14,Limb Position X(2,16)+1.2,Limb Position Y(2,16)+.1,Limb Position Z(2,16)+1.2:Rotate Object 14,0,40,0:Set Object Collision To Boxes 14:Color Object 14,rgb(255,0,0):Clone Object 15,14:Position Object 15,Limb Position X(2,17)-1.2,Limb Position Y(2,17)+.1,Limb Position Z(2,17)+1.2:Rotate Object 15,0,-220,0:Set Object Collision To Boxes 15:Color Object 15,rgb(255,0,0):For i = 1 to 3:Make Object Box 15+i,.5,.5,4:Position Object 15+i,16+(i*9),Limb Position Y(2,rr+(i-1))+1,36-i:Color Object 15+i,0:Set Object Collision To Boxes 15+i:Next i For i = 1 to 3:Make Object Box 18+i,4,6.5,2:Position Object 18+i,-40+(i*5),Limb Position Y(2,dd),51:Color Object 18+i,Rgb(255,0,0):Set Object Collision To Boxes 18+i:Next i:Position Object 1,0,-20,40:Do:Balls=0:Score=0:Do:If ReturnKey() And Object Position Y(1)<-20:Balls=Balls+1:Position Object 1,35,6,45:Set Vector3 2,-(Rnd(20.0)/10.0)-.5,0,0:Endif:tx#=Object Position X(1):ty#=Object Position Y(1):tz#=Object Position Z(1):If SpaceKey() Position Object 2,0,0,.5:Else:Position Object 2,0,0,0:Endif:LV3#=Length Vector3(2):If LV3#>2.9:Scale Vector3 2,2,2.9/LV3#:Endif:Position Object 1,Object Position X(1)+X Vector3(2),Object Position Y(1)+Y Vector3(2)-.2,Object Position Z(1)+Z Vector3(2):Kickers():c=Check_Collision(1,0,2,1,0):Position Object 1,X Vector3(20), Y Vector3(20), Z Vector3(20):Set Vector3 2,(Object Position X(1)-tx#),(Object Position Y(1)-ty#),(Object Position Z(1)-tz#):Flipper(1):Flipper(2):Sync_Flag=(Sync_Flag<3)+(Sync_Flag<2)+(SyncFlag<1):If Sync_Flag=1:Set Cursor 0,0:Print "Score: ";Score:Print "Ball: ";Balls Print Prelimb(20):Sync:Endif:if Balls=5 And Object Position Y(1)<-19:Exit:Endif:Loop:Wait 300:Clear Entry Buffer:Do:Set Cursor 0,0:Print "Score: ";Score:Print "Ball: ";Balls:Print:Print "Game Over. Press Any Key":If Inkey$()<>"":Exit:Endif:Sync:Loop:Loop Function Flipper(side):ks=(side=1)*29+(side=2)*157:ang#=(side=1)*30+(side=2)*-210:If KickFlag(side-1)<60 and (KeyState(ks) or KickFlag(side-1)>0):KickFlag(side-1)=KickFlag(side-1)+7:Rotate Limb 2,side,0,ang#-KickFlag(side-1)*((side=1)-(side=2)),0:c=Check_Collision(2,side,1,1,0):If c:Set Vector3 2,X Vector3(2),Y Vector3(2),.5+(Z Vector3(2)*(Z Vector3(2)>0)):Position Object 1,Object Position X(1)+X Vector3(2)*.15,Object Position Y(1)+Y Vector3(2)*.15,Object Position Z(1)+Z Vector3(2):Endif:Endif:If KickFlag(side-1)>59 and KeyState(ks)=0:KickFlag(side-1)=0:Rotate Limb 2,side,0,ang#,0:Endif Endfunction:Function Kickers():k=Object Collision(1,0):Select k:Case 11,12,13:If Kick(k-11)<1:dx#=(Object Position X(1)-Object Position X(k))*.2+X Vector3(2)*.1:dy#=(Object Position Y(1)-Object Position Y(k))*.2+Y Vector3(2)*.15:dz#=(Object Position Z(1)-Object Position Z(k))*.2+Z Vector3(2)*.1:Position Object 1,Object Position X(1)-dx#,Object Position Y(1)-dy#,Object Position Z(1)-dz#:tx#=Object Position X(1):ty#=Object Position Y(1):tz#=Object Position Z(1):Position Object 1,Object Position X(1)+dx#,Object Position Y(1)+dy#,Object Position Z(1)+dz#:Kick(k-11)=7:Score=Score+10:Set Object Emissive k,Rgb(255,100,100):Endif:EndCase:Case 14 Position Object 1,Object Position X(1)-(1.5+X Vector3(2)*.2),Object Position Y(1),Object Position Z(1)-(1.5+Z Vector3(2)*.2):tx#=Object Position X(1):ty#=Object Position Y(1):tz#=Object Position Z(1):Position Object 1,Object Position X(1)+(1.5+X Vector3(2)*.2),Object Position Y(1),Object Position Z(1)+(1.5+Z Vector3(2)*.2):Set Object Emissive 14,Rgb(255,100,100):Kick(3)=7:Score = Score + 1:EndCase:Case 15:Position Object 1,Object Position X(1)+(1.5+X Vector3(2)*.2),Object Position Y(1),Object Position Z(1)-(1.5+Z Vector3(2)*.2):tx#=Object Position X(1):ty#=Object Position Y(1):tz#=Object Position Z(1):Position Object 1,Object Position X(1)-(1.5+X Vector3(2)*.2),Object Position Y(1),Object Position Z(1)+(1.5+Z Vector3(2)*.2):Set Object Emissive 15,Rgb(255,100,100):Kick(4)=7:Score = Score + 1:EndCase:Case 16,17,18 Score = Score + 2:EndCase:Case 19,20,21:Position Object 1,Object Position X(1),Object Position Y(1),Object Position Z(1)+(1.5+Z Vector3(2)*.2):tx#=Object Position X(1):ty#=Object Position Y(1):tz#=Object Position Z(1):Position Object 1,Object Position X(1),Object Position Y(1),Object Position Z(1)-(1.5+Z Vector3(2)*.2):Position Object k,0,-10,0:DropDown=DropDown+1:Kick(4)=7:Score = Score + 10:EndCase:EndSelect:For i = 11 to 15:Kick(i-11)=Kick(i-11)-(Kick(i-11)>0):If Kick(i-11)=1:Set Object Emissive i,0:Endif:A_Constant EndFunction:Function Add_Limb(ObjectID,sx#,sy#,sz#,px#,py#,pz#,ax#,ay#,az#):Make Object Box 3,sx#,sy#,sz#:Make Mesh From Object 3,3:Delete Object 3:i=1:Do:If Limb Exist(ObjectID,i)=0:Exit:Endif:i=i+1:Loop:Add Limb ObjectID,i,3:Offset Limb ObjectID,i,px#,py#,pz#:Rotate Limb ObjectID,i,ax#,ay#,az# EndFunction i:Function Prepare_Limb(ObjectID,LimbID,C_Factor#):arry=ObjectID*20+LimbID:max=1:If MaxArry>1:For i = 1 to MaxArry:If max<PreLimb(i):max=PreLimb(i):Endif:Next i:Endif:If MaxArry<arry:MaxArry=arry:Dim PreLimb(arry) as Integer:PreLimb(arry)=1 Dim LMX(arry,max) as Float:Dim LMY(arry,max) as Float:Dim LMZ(arry,max) as Float:Endif:Lock VertexData for Limb ObjectID,LimbID:VIC=Get Vertexdata Index Count():n=0:LMX(arry,n)=Get VertexData Position X(Get IndexData(0)):LMY(arry,n)=Get VertexData Position Y(Get IndexData(0)):LMZ(arry,n)=Get VertexData Position Z(Get IndexData(0)):c#=C_Factor#*C_Factor#:n=1:For i = 1 to VIC:tx#=Get VertexData Position X(Get IndexData(i)):ty#=Get VertexData Position Y(Get IndexData(i)):tz#=Get VertexData Position Z(Get IndexData(i)):flag=0:For j=1 to n:d#=((tx#-LMX(array,j))*(tx#-LMX(array,j))+(ty#-LMY(array,j))*(ty#-LMY(array,j))+(tz#-LMZ(array,j))*(tz#-LMZ(array,j))):if d#<c# or (tx#=LMX(arry,0) and ty#=LMY(arry,0) and tz#=LMZ(arry,0)) flag=1:Exit:Endif:Next j:If flag=0:n=n+1:If n>max:max=n:PreLimb(arry)=n:Dim LMX(arry,n) as Float:Dim LMY(arry,n) as Float:Dim LMZ(arry,n) as Float:Endif:LMX(arry,n)=tx#:LMY(arry,n)=ty#:LMZ(arry,n)=tz#:Endif:Next i:PreLimb(arry)=n:Unlock VertexData Endfunction:Function LimbMatrix4(ResultMatrix, Object, Limb):AX#=Limb Direction X( Object, Limb ) : AY#=Limb Direction Y( Object, Limb ) : AZ#=Limb Direction Z( Object, Limb ):CX#=Cos(AX#) : SX#=Sin(AX#) : CY#=Cos(AY#) : SY#=Sin(AY#) : CZ#=Cos(AZ#) : SZ#=Sin(AZ#):Set Vector3 EyeVector, Limb Position X( Object, Limb), Limb Position Y( Object, Limb), Limb Position Z( Object, Limb):Set Vector3 LookAtVector, -1.0*SZ#*(-1.0*SX#)+CZ#*SY#*CX#+Limb Position X(Object,Limb), CZ#*(-1.0*SX#)+SZ#*SY#*CX#+Limb Position Y(Object,Limb), CY#*CX#+Limb Position Z(Object,Limb):Set Vector3 LookUpVector, -SZ#*CX#+CZ#*SY#*SX#, CZ#*CX#+SZ#*SY#*SX#, CY#*SX#:Build LookAt LHMatrix4 ResultMatrix, EyeVector, LookAtVector, LookUpVector:r=Inverse Matrix4( ResultMatrix, ResultMatrix ):#Constant A_Constant :Next i:DropDown=DropDown+(DropDown>2):If DropDown>10:Score=Score + 100:DropDown=0:For i = 1 to 3:Position Object 18+i,-40+(i*5),Limb Position Y(2,dd),51:Next i:Endif EndFunction:Function Check_Collision(ObjectID as DWord,LimbID as DWord,TargetID as DWord,accuracy#,cycles):arry=ObjectID*20+LimbID:r=Make Vector3(arry):if Array Count(cflag(0))<arry:Dim cFlag(arry) as Integer:Dim n(arry) as Float:Endif:LimbMatrix4(LimbMatrix, ObjectID, LimbID):st=1.0/accuracy#:MC=PreLimb(arry):If cFlag(arry)=0:n(arry)=1:Set Vector3 arry,Limb Position X(ObjectID,LimbID),Limb Position Y(ObjectID,LimbID),Limb Position Z(ObjectID,LimbID):Else:if n(arry)>1:n(arry)=2:Set Vector3 arry,X Vector3(arry)+Limb Position X(ObjectID,LimbID),Y Vector3(arry)+Limb Position Y(ObjectID,LimbID),Z Vector3(arry)+Limb Position Z(ObjectID,LimbID):Endif:Endif For i = 0+cFlag(arry) to MC step st:Set Vector3 1,LMX(arry,i),LMY(arry,i),LMZ(arry,i):Transform Coords Vector3 1, 1, LimbMatrix:d#=Intersect Object(TargetID,Limb Position X(ObjectID,LimbID),Limb Position Y(ObjectID,LimbID),Limb Position Z(ObjectID,LimbID),X Vector3(1),Y Vector3(1),Z Vector3(1)):if d#>0:Set Vector3 1,X Vector3(1)-Limb Position X(ObjectID,LimbID),Y Vector3(1)-Limb Position Y(ObjectID,LimbID),Z Vector3(1)-Limb Position Z(ObjectID,LimbID):d2#=Length Vector3(1):id2#=d2#-d#:Multiply Vector3 1,-(id2#/d2#):Set Vector3 arry,X Vector3(arry)+(Limb Position X(ObjectID,LimbID)+X Vector3(1))*id2#,Y Vector3(arry)+(Limb Position Y(ObjectID,LimbID)+Y Vector3(1))*id2#,Z Vector3(arry)+(Limb Position Z(ObjectID,LimbID)+Z Vector3(1))*id2#:n(arry)=n(arry)+id2#:Endif:Next i:cFlag(arry)=cFlag(arry)+1:if cFlag(arry)>cycles:cFlag(arry)=0:Endif:Set Vector3 arry,X Vector3(arry)/n(arry),Y Vector3(arry)/n(arry),Z Vector3(arry)/n(arry):Hit=(n(arry)>1) EndFunction Hit `Thanks to Dmitry K for the LimbMartix4() function!