VERSION 5.00 Begin VB.UserControl Airplane BackColor = &H00FFFF80& BackStyle = 0 'Transparent ClientHeight = 405 ClientLeft = 0 ClientTop = 0 ClientWidth = 405 ControlContainer= -1 'True ScaleHeight = 405 ScaleWidth = 405 Begin VB.PictureBox picPlane AutoSize = -1 'True BorderStyle = 0 'None Height = 585 Left = 0 Picture = "aircraft.ctx":0000 ScaleHeight = 585 ScaleWidth = 600 TabIndex = 0 Top = 0 Width = 600 End Begin VB.Image imgStore Height = 495 Index = 7 Left = 4320 Picture = "aircraft.ctx":128A Top = 840 Visible = 0 'False Width = 510 End Begin VB.Image imgStore Height = 495 Index = 6 Left = 3720 Picture = "aircraft.ctx":2034 Top = 840 Visible = 0 'False Width = 495 End Begin VB.Image imgStore Height = 480 Index = 5 Left = 3120 Picture = "aircraft.ctx":2D5A Top = 840 Visible = 0 'False Width = 525 End Begin VB.Image imgStore Height = 495 Index = 4 Left = 2520 Picture = "aircraft.ctx":3B1C Top = 840 Visible = 0 'False Width = 495 End Begin VB.Image imgStore Height = 525 Index = 3 Left = 1920 Picture = "aircraft.ctx":4842 Top = 840 Visible = 0 'False Width = 525 End Begin VB.Image imgStore Height = 480 Index = 2 Left = 1320 Picture = "aircraft.ctx":5748 Top = 840 Visible = 0 'False Width = 480 End Begin VB.Image imgStore Height = 525 Index = 1 Left = 720 Picture = "aircraft.ctx":638A Top = 840 Visible = 0 'False Width = 525 End Begin VB.Image imgStore Height = 480 Index = 0 Left = 120 Picture = "aircraft.ctx":7290 Top = 840 Visible = 0 'False Width = 495 End End Attribute VB_Name = "Airplane" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Public Enum DirecTypes NORTHWEST = 0 NORTH = 1 NORTHEAST = 2 EAST = 3 SOUTHEAST = 4 SOUTH = 5 SOUTHWEST = 6 WEST = 7 End Enum ' private variable (maybe it should be a property) Private Const speedval = 5 'Default Property Values: Const m_def_newTop = 0 Const m_def_newLeft = 0 Const m_def_Enabled = 0 Const m_def_direction = NORTH Const m_def_moving = False Const m_def_altitude = 0 'Property Variables: Dim m_newTop As Integer Dim m_newLeft As Integer Dim m_Enabled As Boolean Dim m_direction As DirecTypes Dim m_moving As Boolean Dim m_altitude As Integer 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=0,0,0,0 Public Property Get Enabled() As Boolean Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events." Enabled = m_Enabled End Property Public Property Let Enabled(ByVal New_Enabled As Boolean) m_Enabled = New_Enabled PropertyChanged "Enabled" End Property 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=7,0,0,0 Public Property Get direction() As DirecTypes 'used when retrieving value of a property, on the right side of an assignment. direction = m_direction End Property Public Property Let direction(ByVal New_direction As DirecTypes) If (New_direction < 0) Or (New_direction > 7) Then MsgBox "New_direction is " + Str(New_direction) MsgBox "Illegal value! Setting direction to NORTH" m_direction = NORTH Else m_direction = New_direction End If PropertyChanged "direction" End Property 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=5 Public Sub turnLeft() If Me.direction > 0 Then Me.direction = Me.direction - 1 Else Me.direction = 7 End If picPlane.Picture = imgStore(direction).Picture End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=5 Public Sub turnRight() If Me.direction < 7 Then Me.direction = Me.direction + 1 Else Me.direction = 0 End If picPlane.Picture = imgStore(direction).Picture End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=5 Public Sub land(airport As Control) 'move as much of the landing code here as possible 'make some variables to simplify analysis Dim apTop As Integer Dim apBottom As Integer Dim apLeft As Integer Dim apRight As Integer Dim plnTop As Integer Dim plnBottom As Integer Dim plnLeft As Integer Dim plnright As Integer Dim apSizeOK As Boolean Dim directionOK As Boolean 'assign values to variables apTop = airport.Top apBottom = airport.Top - airport.Height apLeft = airport.Left apRight = airport.Left + airport.Width plnTop = Extender.Top plnBottom = Extender.Top - Extender.Height plnLeft = Extender.Left plnright = Extender.Left + Extender.Width apSizeOK = False directionOK = True 'Ensure airport is larger than plane!! If airport.Width > Extender.Width Then If airport.Height > Extender.Height Then apSizeOK = True End If End If If apSizeOK Then If plnLeft > apLeft Then If plnright < apRight Then If plnTop < apTop Then If plnBottom > apBottom Then If Me.altitude <= 5 Then If directionOK Then 'we can land safely Me.moving = False Me.altitude = 0 MsgBox "nice landing..." Else MsgBox "can't land in this direction!!" End If 'directionOK Else MsgBox "altitude too high!!" End If 'altitude Else MsgBox "too far south" End If 'bottom comparison Else MsgBox "too far north" End If 'top compare Else MsgBox "too far east" End If 'right compare Else MsgBox "too far west" End If 'left compare Else 'apsize is not OK MsgBox "the airport is too small for this plane!!" End If 'airport size End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=5 Public Sub takeOff() Me.moving = True Me.altitude = 5 End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=5 Public Sub goForward() 'analyzes direction, generates new values for left and top 'expects CARTESIAN coordinates (top is larger at top of page) Me.newLeft = Extender.Left Me.newTop = Extender.Top If (Me.moving = True) Then Select Case Me.direction Case NORTH Me.newLeft = Extender.Left + 0 Me.newTop = Extender.Top + speedval Case NORTHEAST Me.newLeft = Extender.Left + speedval Me.newTop = Extender.Top + speedval Case EAST Me.newLeft = Extender.Left + speedval Me.newTop = Extender.Top + 0 Case SOUTHEAST Me.newLeft = Extender.Left + speedval Me.newTop = Extender.Top - speedval Case SOUTH Me.newLeft = Extender.Left + 0 Me.newTop = Extender.Top - speedval Case SOUTHWEST Me.newLeft = Extender.Left - speedval Me.newTop = Extender.Top - speedval Case WEST Me.newLeft = Extender.Left - speedval Me.newTop = Extender.Top + 0 Case NORTHWEST Me.newLeft = Extender.Left - speedval Me.newTop = Extender.Top + speedval End Select End If End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=0,0,0,0 Public Property Get moving() As Boolean moving = m_moving End Property Public Property Let moving(ByVal New_moving As Boolean) m_moving = New_moving PropertyChanged "moving" End Property 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=7,0,0,0 Public Property Get altitude() As Integer altitude = m_altitude End Property Public Property Let altitude(ByVal New_altitude As Integer) m_altitude = New_altitude PropertyChanged "altitude" End Property 'Initialize Properties for User Control Private Sub UserControl_InitProperties() m_Enabled = m_def_Enabled m_direction = m_def_direction m_moving = m_def_moving m_altitude = m_def_altitude m_newTop = m_def_newTop m_newLeft = m_def_newLeft End Sub 'Load property values from storage Private Sub UserControl_ReadProperties(PropBag As PropertyBag) m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled) m_direction = PropBag.ReadProperty("direction", m_def_direction) m_moving = PropBag.ReadProperty("moving", m_def_moving) m_altitude = PropBag.ReadProperty("altitude", m_def_altitude) m_newTop = PropBag.ReadProperty("newTop", m_def_newTop) m_newLeft = PropBag.ReadProperty("newLeft", m_def_newLeft) End Sub 'Write property values to storage Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled) Call PropBag.WriteProperty("direction", m_direction, m_def_direction) Call PropBag.WriteProperty("moving", m_moving, m_def_moving) Call PropBag.WriteProperty("altitude", m_altitude, m_def_altitude) Call PropBag.WriteProperty("newTop", m_newTop, m_def_newTop) Call PropBag.WriteProperty("newLeft", m_newLeft, m_def_newLeft) End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=7,0,0,0 Public Property Get newTop() As Integer newTop = m_newTop End Property Public Property Let newTop(ByVal New_newTop As Integer) m_newTop = New_newTop PropertyChanged "newTop" End Property 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MemberInfo=7,0,0,0 Public Property Get newLeft() As Integer newLeft = m_newLeft End Property Public Property Let newLeft(ByVal New_newLeft As Integer) m_newLeft = New_newLeft PropertyChanged "newLeft" End Property