Wyo VB Lecture Notes

Objective #1: Be able to use various Mouse events.

    ' move player around screen with mouse
    Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        picPlayer.Left = e.X - picPlayer.Width / 2
        picPlayer.Top = e.Y - picPlayer.Height / 2
        ' Can you explain why the statement above is 
        ' better than the shorter statement:         picPlayer.Top = e.Y

       
        If (picPlayer.Left < 200 And picPlayer.Right > 200 And picPlayer.Top < 150 And picPlayer.Bottom > 100) Then
            MessageBox.Show("collision")
        End If

    End Sub
    
    ' draw maze
    Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawLine(Pens.Black, 200, 100, 200, 150)
    End Sub