' Ch 7 Demo #8
' Mr Minich
' This program illustrates collision detection & shape objects
Option Explicit Private Sub Form_Load() Form1.AutoRedraw = True Form1.ScaleMode = 0 Form1.ScaleWidth = 100 Form1.ScaleHeight = 100 Form1.Line (25, 50)-(75, 50) Shape1.Top = 0 Shape1.Left = 0 Shape1.Width = 10 End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button = vbLeftButton) Then Shape1.Left = X - Shape1.Width / 2 Shape1.Top = Y - Shape1.Height / 2 If (Shape1.Top < 50 And Shape1.Top + Shape1.Height > 50 And Shape1.Left + Shape1.Width > 25 And Shape1.Left < 75) Then MsgBox "Collision" End If End If End Sub