Sub StartBlink
Timer.Interval = 100
Timer.Tick = OnTick
EndSub
Sub OnTick
' work t - times
t = t + 1
If Math.Remainder(t, 30) = 0 Then
open = "False"
Blink()
ElseIf Math.Remainder(t, 30) = 5 Then
open = "True"
Blink()
EndIf
If opBl <> "" Then
nSp = Array.GetItemCount(opBl)
xSp = Array.GetAllIndices(opBl)
For _j = 1 To nSp
iSp = xSp[_j]
_opBl = opBl[iSp]
nRp = Array.GetItemCount(_opBl)
xRp = Array.GetAllIndices(_opBl)
For _i = 1 To nRp
iRp = xRp[_i]
If (_opBl[iRp] = 100) Then
Balloon()
_opBl[iRp] = 99
opBl[iSp] = _opBl
bt[iRp][iRp] = t + 10
ElseIf (0 < _opBl[iRp]) And (bt[iRp][iRp] < t) Then
_opBl[iRp] = ""
opBl[iSp] = _opBl
Balloon()
EndIf
EndFor
EndFor
EndIf
If snowing Then
Timer.Pause()
If Math.Remainder(t, 10) = 0 Then
iSnow = iSnow + 1
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "White"
snow[iSnow] = Shapes.AddEllipse(6, 6)
Shapes.Move(snow[iSnow], Math.GetRandomNumber(gw), 0)
EndIf
nSnow = Array.GetItemCount(snow)
xSnow = Array.GetAllIndices(snow)
For _i = 1 To nSnow
sign = (Math.GetRandomNumber(2) - 1.5) * 2
_x = Shapes.GetLeft(snow[xSnow[_i]]) + sign * 2
_y = Shapes.GetTop(snow[xSnow[_i]]) + 2
Shapes.Move(snow[xSnow[_i]], _x, _y)
If gh < _y Then
Shapes.Remove(snow[xSnow[_i]])
snow[xSnow[_i]] = ""
ElseIf GraphicsWindow.GetPixel(_x, _y) = colorHill Then
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillEllipse(_x, _y, 6, 6)
snow[xSnow[_i]] = ""
EndIf
EndFor
Timer.Resume()
EndIf
EndSub
Sub Blink
' work iSp - splite
' work iRp - repeat
' work iEy - eye
For iSp = 1 To Array.GetItemCount(s)
_eyes = eyes[iSp]
For iRp = 1 To Array.GetItemCount(s[iSp])
_shp = shp[iSp + ":" + iRp]
For iEy = 1 To Array.GetItemCount(_eyes)
_eye = _eyes[iEy]
If open Then
Shapes.ShowShape(_shp[_eye])
Else
Shapes.HideShape(_shp[_eye])
EndIf
EndFor
EndFor
EndFor
EndSub
Sub StartKeyInput
GraphicsWindow.KeyDown = OnKeyDown
EndSub
Sub OnKeyDown
' work _iSp - splite
' work _iRp - repeat
key = GraphicsWindow.LastKey
For _iSp = 1 To Array.GetItemCount(s)
For _iRp = 1 To Array.GetItemCount(s[_iSp])
If Array.ContainsIndex(keys[_iSp][_iRp], key) Then
dir = keys[_iSp][_iRp][key]
MoveShapes()
x1 = helloSpots[_iSp][_iRp]["x1"]
y1 = helloSpots[_iSp][_iRp]["y1"]
x2 = helloSpots[_iSp][_iRp]["x2"]
y2 = helloSpots[_iSp][_iRp]["y2"]
If (x1 <= x) And (x <= x2) And (y1 <= y) And (y <= y2) Then
opBl[_iSp][_iRp] = 100
EndIf
EndIf
EndFor
EndFor
EndSub
Sub MoveShapes
' param dir - direction
' param _iSp - splite
' param _iRp - repeat
' work _iSh - shape
__shp = shp[_iSp + ":" + _iRp]
For _iSh = 1 To Array.GetItemCount(__shp)
x = Shapes.GetLeft(__shp[_iSh]) + dx[dir]
y = Shapes.GetTop(__shp[_iSh]) + dy[dir]
Shapes.Move(__shp[_iSh], x, y)
EndFor
EndSub
Sub Balloon
' param iSp - splite
' param iRp - repeat
' param opBl[iSp][iRp] - opacity
nSh = Array.GetItemCount(balloons[iSp])
xSh = Array.GetAllIndices(balloons[iSp])
_shp = shp[iSp + ":" + iRp]
For iSh = 1 To nSh
Shapes.SetOpacity(_shp[balloons[iSp][xSh[iSh]]], opBl[iSp][iRp])
EndFor
EndSub