Please someone help me . I want a picturebox to move form one point to another point (Drag n Drop) and I want to know how to check whether the point is empty or not. if empty movable otherwise move to another empty point.
I have managed to make two player drag and move turn by turn but I can`t figure out how to check the point
Thank You
I have managed to make two player drag and move turn by turn but I can`t figure out how to check the point
Thank You
Dim NextMove As Boolean Dim MouseIsClicked As Boolean Dim LeftSet As Boolean Dim TopSet As Boolean Dim HoldLeft As Integer Dim HoldTop As Integer Dim LetLeft As Integer Dim LetTop As Integer Dim RowA As Point() ={New Point(40, 40), New Point(140, 40), New Point(240, 40), New Point(340, 40), New Point(440,40)} Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp MouseIsClicked = False LeftSet = False TopSet = False NextMove = False First Row of Board If sender.left <= 90 And sender.top <= 90 Then PictureBox1.Location = RowA(0) End If If sender.left > 90 And sender.left <= 190 And sender.top <= 90 Then PictureBox1.Location = RowA(1) End If If sender.left > 190 And sender.left <= 290 And sender.top <= 90 Then PictureBox1.Location = RowA(2) End If If sender.left > 290 And sender.left <= 390 And sender.top <= 90 Then PictureBox1.Location = RowA(3) End If If sender.left > 390 And sender.left <= 490 And sender.top <= 90 Then PictureBox1.Location = RowA(4) End If Label2.Text = (" Player 2`s Turn") NextMove = True End Sub Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown If NextMove = False Then MouseIsClicked = True End If End Sub Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove ' check for mouse clicked? If MouseIsClicked = True Then HoldLeft = (Control.MousePosition.X - Me.Left) HoldTop = (Control.MousePosition.Y - Me.Top) If LeftSet = False Then LetLeft = HoldLeft - sender.left LeftSet = True End If If TopSet = False Then LetTop = HoldTop - sender.top TopSet = True End If sender.left = HoldLeft - LetLeft sender.top = HoldTop - LetTop End If End Sub Private Sub PictureBox2_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseUp MouseIsClicked = False LeftSet = False TopSet = False 'First Row of Board If sender.left <= 90 And sender.top <= 90 Then PictureBox2.Location = RowA(0) End If If sender.left > 90 And sender.left <= 190 And sender.top <= 90 Then PictureBox2.Location = RowA(1) End If If sender.left > 190 And sender.left <= 290 And sender.top <= 90 Then PictureBox2.Location = RowA(2) End If If sender.left > 290 And sender.left <= 390 And sender.top <= 90 Then PictureBox2.Location = RowA(3) End If If sender.left > 390 And sender.left <= 490 And sender.top <= 90 Then PictureBox2.Location = RowA(4) End If NextMove = False Label2.Text = ("Player 1`s Turn") End Sub Private Sub PictureBox2_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseDown If NextMove = True Then MouseIsClicked = True End If End Sub Private Sub PictureBox2_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseMove ' check for mouse clicked? If MouseIsClicked = True Then HoldLeft = (Control.MousePosition.X - Me.Left) HoldTop = (Control.MousePosition.Y - Me.Top) If LeftSet = False Then LetLeft = HoldLeft - sender.left LeftSet = True End If If TopSet = False Then LetTop = HoldTop - sender.top TopSet = True End If sender.left = HoldLeft - LetLeft sender.top = HoldTop - LetTop End If End Sub