End Sub
Public Sub StopJump()
If picState = BallState.JUMPING_BALL Then
picState = 0
myTimer.Enabled = False
RemoveHandler myTimer.Tick, AddressOf TimerEventJump
Me.Top = picTop
Me.Left = picLeft
Me.Height = picHeight
Me.Width = picWidth
End If
End Sub
Private Sub TimerEventJump(ByVal myObject As Object, _
ByVal myEventArgs As EventArgs)
Me.Height -= sign * 1
Me.Top = picTop + (Me.Height – picHeight) \ 4
If Me.Height = picHeight Or Me.Height <= 3 * picHeight / 4 Then
sign *= -1
End If
End Sub
Public Sub Destroy()
If picState = BallState.JUMPING_BALL Then
StopJump()
End If
picState = BallState.DESTROYING_BALL
AddHandler myTimer.Tick, AddressOf TimerEventDestroy
Me.Top = picTop + 1
Me.Left = picLeft + 1
Me.Width = picWidth – 2
Me.Height = picHeight – 2
myTimer.Interval = 10
myTimer.Start()
End Sub
Private Sub TimerEventDestroy(ByVal myObject As Object, _
ByVal myEventArgs As EventArgs)
If Me.Top > picTop And Me.Width > 0 Then
Me.Top += 2
Me.Left += 2
Me.Width -= 4
Me.Height -= 4
Else
Me.Image = Nothing
Me.Top = picTop
Me.Left = picLeft
Me.Width = picWidth
Me.Height = picHeight
myTimer.Enabled = False
Me.picState = BallState.NO_BALL
Me.picIndex = -1
Me.Tag = ""
RemoveHandler myTimer.Tick, AddressOf TimerEventDestroy
End If
End Sub
Public Sub Reset()
While Me.picState = BallState.DESTROYING_BALL
Application.DoEvents()
End While
If Me.picState = BallState.JUMPING_BALL Then
StopJump()
End If
While Me.picState = BallState.ZOOMING_BALL
Application.DoEvents()
End While
Me.Image = Nothing
Me.picIndex = -1
Me.picState = BallState.NO_BALL
Me.Tag = ""
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As _
System.Windows.Forms.MouseEventArgs)
If picState = BallState.NORMAL_BALL Or _
picState = BallState.JUMPING_BALL Then
Me.Image = Image.FromFile(ImgList(picIndex + 1))
End If
End Sub
Protected Overrides Sub OnMouseLeave( _
ByVal e As System.EventArgs)
If picState = BallState.NORMAL_BALL Or picState = _
BallState.JUMPING_BALL Then
Me.Image = Image.FromFile(ImgList(picIndex))
End If
End Sub
End Class
После этих добавлений (DPaint.vb, mModule.vb, MotionPic.vb, open.ico, save.ico) в панели Solution Explorer должны быть файлы, показанные выше. Дважды щёлкая по имени файла, любой файл можно открыть, изучить и редактировать.
Теперь в наш проект добавляем переменные и методы, связанные с формой Form2 для вывода результатов игры.
Открываем файл Form2.vb (например, так: File, Open, File) и вверху записываем директивы для подключения требуемых пространств имен:
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.IO
Теперь в классе Form2 нашего проекта записываем следующие переменные и методы.
Листинг 21.12. Переменные и методы.
Dim gr As Graphics
Dim lbrTitle As LinearGradientBrush
Dim lbrBoard As LinearGradientBrush
Dim midPoint As Point
Dim СКАЧАТЬ