Advertisement
Guest User

PacmanActor

a guest
Jan 13th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class PacmanActor
  2.  
  3.     Private ReadOnly m_PacmanLabel As Label
  4.     Private ReadOnly m_Field As Panel
  5.     Private m_Done As Boolean
  6.     Private m_Rule As MovementRule
  7.  
  8.     Public Property Coordinates() As Point
  9.         Get
  10.             Return m_PacmanLabel.Location
  11.         End Get
  12.         Set(ByVal value As Point)
  13.             m_PacmanLabel.Location = value
  14.         End Set
  15.     End Property
  16.  
  17.     Public ReadOnly Property Done() As Boolean
  18.         Get
  19.             Return m_Done
  20.         End Get
  21.     End Property
  22.  
  23.     Public Sub New(aField As Panel)
  24.         m_PacmanLabel = New Label()
  25.         m_PacmanLabel.Text = "O<"
  26.         m_PacmanLabel.Visible = False
  27.         m_Field = aField
  28.         m_Done = False
  29.     End Sub
  30.  
  31.     Public Sub StartUp(aCoordinates As Point, aRule As MovementRule)
  32.         m_PacmanLabel.Location = aCoordinates
  33.         m_Done = False
  34.         m_Field.Controls.Add(m_PacmanLabel)
  35.         m_PacmanLabel.Visible = True
  36.         m_Rule = aRule
  37.     End Sub
  38.  
  39.     Public Sub ShutDown()
  40.         m_PacmanLabel.Visible = False
  41.         m_Field.Controls.Remove(m_PacmanLabel)
  42.     End Sub
  43.  
  44.     Public Sub Move()
  45.         If Not m_Done Then
  46.             Dim lNewCoords As Point
  47.             m_Done = Not m_Rule.Evaluate(m_PacmanLabel.Location, lNewCoords)
  48.             If Not m_Done Then
  49.                 m_PacmanLabel.Location = lNewCoords
  50.                 Application.DoEvents()
  51.             End If
  52.         End If
  53.     End Sub
  54.  
  55. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement