so i'm working on developing a Monopoly game for class in VB and i'm having difficulties with moving the game pieces. how i have it set up right now is that the pieces are moved by the location property through a loop that's as big as the dice roll. the difficulty lies in how can i detect when the player is at the corner pieces and instead of going left off the form instead goes up on the board instead of left into nothingness.
so far i have:
to make it easier for others, 42 is the difference on the boards from left to right on the board and 37 is the distance from top to bottom between placesCode:Private Sub btnRoll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRoll.Click Dim die1, die2 As Integer Dim rnd As New Random() Randomize() die1 = rnd.Next(1, 7) die2 = rnd.Next(1, 7) lblDiceRoll1.Text = die1.ToString lblDiceRoll2.Text = die2.ToString playerPosition = die1 + die2 Randomize() die1 = rnd.Next(1, 7) die2 = rnd.Next(1, 7) lblAiRoll1.Text = die1.ToString lblAiRoll2.Text = die2.ToString aiPosition = die1 + die2 tmrMove.Enabled = True End Sub Private Sub tmrMove_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick If (playerPosition > 0 And aiPosition > 0) Then movePlayer() moveComputer() ElseIf (playerPosition > 0) Then movePlayer() ElseIf (aiPosition > 0) Then moveComputer() Else tmrMove.Enabled = False End If playerPosition -= 1 aiPosition -= 1 End Sub Private Sub movePlayer() lblPlayer1.Left -= 42 End Sub




Reply With Quote