Sub EnemyMove(ByRef redball As PictureBox, ByVal intMoveX As Integer, ByVal intMoveY As Integer, ByVal intMultiplierX As Integer, ByVal intMultiplierY As Integer)
Dim intCX As Integer = redball.Location.X
Dim intCY As Integer = redball.Location.Y
'If intCX >= 707 Then
intCX += intMoveX * intMultiplierX 'Redball movement X
intCY += intMoveY * intMultiplierY 'Redball movement Y
redball.Location = New Point(intCX, intCY) 'setting new position
If redball.Bounds.IntersectsWith(UserPicBox1.Bounds) Or redball.Bounds.IntersectsWith(UserPicBox2.Bounds) Or redball.Bounds.IntersectsWith(UserPicBox3.Bounds) Then
CompMove.Enabled = False
MessageBox.Show("Hit")
btnReset.Enabled = True
Time.Enabled = False
intTime = 0
intDeaths += 1
Me.lblDeaths.Text = intDeaths
End If
End Sub
All of the multipliers are equal to one to start, but I change them then declare a temporary variable as shown below. However, the balls still cling together often and do not break apart.
If pctCompBall1.Bounds.IntersectsWith(pctCompBall2.Bounds) Then
intTemX = intCX1horizontal
intTemY = intCY1verticle
intCX1horizontal = intCX2horizontal
intCY1verticle = intCY2verticle
intCX2horizontal = intTemX
intCY2verticle = intTemY