' ==============================Cannon Animation and Blinkig 1======================
While "True" '
NN=NN+1 '<----****
If Math.Remainder(NN,7)=0 Then '<----****
For k=1 To Array.GetItemCount(s[6])
For L=1 To Array.GetItemCount(shape[6])-2 '
Shapes.Rotate(SHP["6:"+k][L],Shape[6][L]["angle"])
EndFor
EndFor
EndIf
DuckBlinking() '<----****
DuckFire() '<----****
CannonFire() '<----****
If Math.Remainder(NN,11)=0 Then '<----****
For k=1 To Array.GetItemCount(s[6])
For L=1 To Array.GetItemCount(shape[6])-2 '
Shapes.Rotate(SHP["6:"+K][L], 0)
EndFor
EndFor
EndIf
Program.Delay(25)
EndWhile
Sub DuckBlinking
'============================Duck Blinking Program=======================
zoom = zoom - dZ
sprite = 5
For ii=1 To 4 '<----****
ANMB="5:"+ii '<----****
ss = s[sprite][ii]
For i = 1 To Array.GetItemCount(shape[5])
If Array.ContainsValue(shape[5][i], "eye") Or Array.ContainsValue(shape[5][i], "wing1") Or Array.ContainsValue(shape[5][i], "wing2") Then
Shapes.Zoom(shp[ANMB][i], 1, zoom)
EndIf
If Array.ContainsValue(shape[5][i], "wing1") Or Array.ContainsValue(shape[5][i], "wing2") Then
Shapes.Move(shp[ANMB][i], Shapes.GetLeft(shp[ANMB][i]), Shapes.GetTop(shp[ANMB][i])+dZ*20*ss)
EndIf
Shapes.Move(shp[ANMB][i],Shapes.GetLeft(shp[ANMB][i])+ddx[ii],Shapes.GetTop(shp[ANMB][i])+ddy)'<----****
EndFor
ax[ANMB] = ax[ANMB] + ddx[ii]
'============================Aircraft Reverse Moving=====X,Y Direction=============
cycleX[ii]= shapes.GetLeft(shp[ANMB][9]) '<----****
cycley[ii]= shapes.Gettop(shp[ANMB][9]) '<----****
If cycleX[ii]<-100 Or cycleX[ii]>GraphicsWindow.Width+100 Then'<----****
ddx[ii]=-ddx[ii] '<----****
Flip_Holizontal()
EndIf
endfor '<----****
If zoom = 0.1 Or zoom = 1 Then
dZ = -dZ
EndIf
EndSub
Sub DuckFire
' ===========================BallFire=======================================
bn= Math.GetRandomNumber(10) '<----****
For i=1 To 4 '<----****
If sht[i]="True" Then '<----****
Shapes.ShowShape(Ball[i]) '<----****
shapes.Move(Ball[i] ,shapes.GetLeft(ball[i])+bdx/2,shapes.Gettop(ball[i])+bdy/2) '<----****
If shapes.Gettop(ball[i])>700 Then '<----****
sht[i]="False" '<----****
GraphicsWindow.Title="You Hit !!!!!! Total "
Shapes.Move(Ball[i],shapes.GetLeft(shp["5:"+bn/2][9])+10,shapes.Gettop(shp["5:"+bn/2][9])+30)'<----****
Shapes.HideShape(Ball[i]) '<----****
EndIf
'==========================Collision Check Here=================================
Cannon_X=shapes.GetLeft(shp[CNMB][5])
Cannon_Y=shapes.GetTop(shp[CNMB][5])
ballX=shapes.GetLeft(ball[i]) '<----****
bally=shapes.GetTop(ball[i]) '<----****
If (Cannon_X
GraphicsWindow.Title="Duck Hit Cannon!!!!!!"
Sound.PlayChimeAndWait()
sht[i]="False" '<----****
Shapes.Move(Ball[i],shapes.GetLeft(shp["5:"+i][9])+10,shapes.Gettop(shp["5:"+i][9])+30)'<----****
Shapes.HideShape(Ball[i]) '<----****
EndIf
EndIf
EndFor
EndSub
Sub CannonFire
For j=1 To shootNMB '<----****
If sht2[j] Then '<----****
shapes.Move(Ball2[j] ,shapes.GetLeft(ball2[j] )+angle/4,shapes.Gettop(ball2[j] )-bdy2) '<----****
If shapes.Gettop(ball2[j] )<-100 Then '<----****
sht2[j] ="False" '<----****
Shapes.Move(Ball2[j] ,shapes.GetLeft(shp[CNMB][14]),shapes.Gettop(shp[CNMB][14])) '<----****
Shapes.HideShape(Ball2[j] ) '<----****
EndIf
endif
' Collision Check Here
ballX2=shapes.GetLeft(ball2[j] ) '<----****
bally2=shapes.GetTop(ball2[j] ) '<----****
For k=1 to 4
cycleX=shapes.GetLeft(shp["5:"+k][5]) '<----****
cycley= shapes.Gettop(shp["5:"+k][5]) '<----****
If (cycleX
GraphicsWindow.Title="Cannon Hit Duck!!!!!!!!!!!"
Sound.PlayChimeAndWait()
sht2[j]="False" '<----****
Shapes.Move(Ball2[j] ,shapes.GetLeft(shp[CNMB][14]),shapes.Gettop(shp[CNMB][14])) '<----****
Shapes.HideShape(Ball2[j] ) '<----****
K=4 '<----****
EndIf
EndFor
EndFor
EndSub
' ==================KeyBoard Aniation Keys S, W, A, T, X,Z,F , SpaceBar works===========================
Sub OnKeyDown
key= GraphicsWindow.LastKey
'If shoot2="False" Then
L1415=(shape[6][14]["height"]+shape[6][15]["height"])/2*s[6][1]
cx14= Shapes.GetLeft(shp[CNMB][14])+shape[6][14]["width"]/2*s[6][1]
cy14= Shapes.Gettop(shp[CNMB][14])+shape[6][14]["height"]/2*s[6][1]
If Key = "X" Then
angle=angle+1
Shapes.Rotate(shp[CNMB][14],angle)
X15= L1415*math.Sin(Math.GetRadians(angle))+cx14-shape[6][15]["width"]/2*s[6][1]
y15= -L1415*math.cos(Math.GetRadians(angle))+cy14-shape[6][15]["height"]/2*s[6][1]
Shapes.Move(shp[CNMB][15],x15,y15)
Shapes.Rotate(shp[CNMB][15],angle)
ElseIf Key = "Z" Then
angle=angle-1
Shapes.Rotate(shp[CNMB][14],angle)
X15= L1415*math.Sin(Math.GetRadians(angle))+cx14-shape[6][15]["width"]/2*s[6][1]
y15= -L1415*math.cos(Math.GetRadians(angle))+cy14-shape[6][15]["height"]/2*s[6][1]
Shapes.Move(shp[CNMB][15],x15,y15)
Shapes.Rotate(shp[CNMB][15],angle)
elseIf Key="F" Then
MM=MM+1 '<----****
Shapes.ShowShape(Ball2[MM]) '<----****
Shapes.Move(Ball2[MM],shapes.GetLeft(shp[CNMB][14]),shapes.Gettop(shp[CNMB][14])) '<----****
Shapes.Rotate(Ball2[MM],angle) '<----****
sht2[MM]="True" '<----****
If mm=shootNMB then '<----****
mm=0 '<----****
EndIf '<----****
EndIf
'EndIf
PMXY= text.GetCharacterCode(key)
If PMXY=76 Or PMXY=82 Then ' Left Arrow : 76 Right Arrow : 82
dX= (PMXY-79)/3*5 ' <-- (82-76)/2=3 ,82-3=79 , dX=+5 or -5
dY=0
Move_index()
ElseIf PMXY=68 Or PMXY=85 Then ' Up Arrow : 85 Down Arrow : 68
dY= (76.5-PMXY)/8.5*5 ' <-- (85-68)/2=8.5, 85-8.5=76.5, dY=+5 or -5
dx=0
Move_index()
EndIf
EndSub
' ======================Move Sprite on Screen===================================
Sub move_index
For N=1 To 15 ''<----****
Shapes.Move(shp[CNMB][N],Shapes.GetLeft(shp[CNMB][N])+dX,Shapes.Gettop(shp[CNMB][N])+dY)'<----****
EndFor
EndSub
' ==============================Add Sprites=========================================
Sub Add_Shapes
For M=1 To Array.GetItemCount(s)
For N=1 To Array.GetItemCount(s[M])
ss=s[M][N]
_shx=shx[M][N]
_shY=shY[M][N]
_shape=shape[M]
NMB=M+":"+N
For i=1 To Array.GetItemCount(_shape)
GraphicsWindow.PenWidth = _shape[i]["pw"]
GraphicsWindow.BrushColor = _shape[i]["bc"]
GraphicsWindow.penColor = _shape[i]["pc"]
If _shape[i]["func"]="ell" Then
shp[NMB][i] = Shapes.AddEllipse(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
ElseIf _shape[i]["func"]="rect" Then
shp[NMB][i] = Shapes.AddRectangle(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
ElseIf _shape[i]["func"]="tri" Then
shp[NMB][i] = Shapes.Addtriangle(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss, _shape[i]["x3"]*ss, _shape[i]["y3"]*ss)
ElseIf _shape[i]["func"]="line" Then
shp[NMB][i] = Shapes.Addline(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss)
EndIf
Shapes.Animate(shp[NMB][i], _shape[i]["x"]*ss+_shX, _shape[i]["y"]*ss+_shY, 500)
Shapes.Rotate(shp[NMB][i], _Shape[i]["angle"])
EndFor
EndFor
EndFor
EndSub
Sub Flip_Holizontal
' param sprite - sprite number
' param ii - copy number
' param ddx[ii] - direction
FNMB = sprite + ":" + ii
If ax[FNMB] = "" Then
xmin = ""
xmax = ""
For i = 1 To Array.GetItemCount(shape[sprite])
_shp = shape[sprite][i]
x = shapes.GetLeft(shp[FNMB][i])
If _shp["width"] = "" Then
_xmin = ""
_xmax = ""
If _shp["func"] = "line" Then
jmax = 2
ElseIf _shp["func"] = "tri" Then
jmax = 3
EndIf
For j = 1 To jmax
If (_xmin = "") Or (_shp["x" + j] < _xmin) Then
_xmin = _shp["x" + j]
EndIf
If (_xmax = "") Or (_xmax < _shp["x" + j]) Then
_xmax = _shp["x" + j]
EndIf
EndFor
_shp["width"] = _xmax - _xmin
EndIf
cx = x + _shp["width"] / 2 * s[sprite][ii]
If (xmin = "") Or (cx - _shp["width"] / 2 * s[sprite][ii] < xmin) Then
xmin = cx - _shp["width"] / 2 * s[sprite][ii]
EndIf
If (xmax = "") Or (xmax < cx + _shp["width"] / 2 * s[sprite][ii]) Then
xmax = cx + _shp["width"] / 2 * s[sprite][ii]
EndIf
shape[sprite][i] = _shp
EndFor
ax[FNMB] = (xmin + xmax) / 2
EndIf
For i = 1 To Array.GetItemCount(shape[sprite])
_shp = shape[sprite][i]
x = shapes.GetLeft(shp[FNMB][i])
cx = x + _shp["width"] / 2 * s[sprite][ii]
If cx < ax[FNMB] Then
_dx = ax[FNMB] - cx
cx = ax[FNMB] + _dx
Else
_dx = cx - ax[FNMB]
cx = ax[FNMB] - _dx
EndIf
x = cx - _shp["width"] / 2 * s[sprite][ii]
Shapes.Move(shp[FNMB][i],x,shapes.Gettop(shp[FNMB][i]))
If 0 < ddx[ii] Then
Shapes.Rotate(shp[FNMB][i],_shp["angle"])
Else
Shapes.Rotate(shp[FNMB][i],-_shp["angle"])
EndIf
EndFor
EndSub