?? applebug.vb
字號(hào):
Public MustInherit Class AppleBug
Protected m_p As PictureBox
Public MustOverride Function Create(ByVal left As Integer, ByVal top As Integer) As PictureBox
Public MustOverride Function getObject() As PictureBox
Public MustOverride Sub Destroy()
End Class
Public Class Bug
Inherits AppleBug
Public Overrides Function Create(ByVal left As Integer, ByVal top As Integer) As PictureBox
m_p = New PictureBox
m_p.Left = left
m_p.Top = top
m_p.ImageLocation = "bug.gif"
m_p.SizeMode = PictureBoxSizeMode.AutoSize
m_p.Visible = True
Return m_p
End Function
Public Overrides Function getObject() As System.Windows.Forms.PictureBox
Return m_p
End Function
Public Overrides Sub Destroy()
m_p.Visible = False
m_p.Dispose()
End Sub
Public Sub MoveTo(ByVal left As Integer, ByVal top As Integer)
If m_p Is Nothing Then
Create(left, top)
Else
m_p.Left = left
m_p.Top = top
End If
End Sub
End Class
Public Class Apple
Inherits AppleBug
Public Overrides Function Create(ByVal left As Integer, ByVal top As Integer) As PictureBox
m_p = New PictureBox
m_p.Left = left
m_p.Top = top
m_p.ImageLocation = "apple.gif"
m_p.SizeMode = PictureBoxSizeMode.AutoSize
m_p.Visible = True
Return m_p
End Function
Public Overrides Function getObject() As System.Windows.Forms.PictureBox
Return m_p
End Function
Public Overrides Sub Destroy()
m_p.Visible = False
m_p.Dispose()
End Sub
End Class
Public Class Utilities
'initialize random number generator
Private Shared _r As New Random(System.DateTime.Now.Millisecond)
Public Shared Function RandomNumber(ByVal UpperRange As Integer, Optional ByVal LowerRange As Integer = 0) As Integer
If LowerRange > UpperRange Then
Dim t As Integer = LowerRange
LowerRange = UpperRange
UpperRange = t
End If
Return _r.Next(LowerRange, UpperRange)
End Function
Public Shared Function CheckOverlap(ByVal bug1 As Bug, ByVal apple1 As Apple) As Boolean
If bug1.getObject().Left >= apple1.getObject().Left And _
bug1.getObject().Top >= apple1.getObject().Top And _
(bug1.getObject().Left + bug1.getObject().Width) <= (apple1.getObject().Left + apple1.getObject().Width) And _
(bug1.getObject().Top + bug1.getObject().Height) <= (apple1.getObject().Top + apple1.getObject().Height) Then
Return True
Else
Return False
End If
End Function
End Class
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -