VB help needed please

Soldato
Joined
25 Jul 2006
Posts
3,529
Location
Taunton
Right im creating a simple game of snakes and ladders and im confused by the last steps of the game. (Ie. where you have to roll the exact number to finish the game, or if you roll over that number you move back the remaining spaces)

so this is the code i have so far but cant for the life of me figure out how to get it to go up to 99 (effectively the 100th square but due to array's ...) and then backwards, i know my code doesnt exactly help what i want to do as its just adding the dice roll every time, but as i said i cant figure it out :confused:

Code:
    EndPosition = MyPosition + Text1        'myposition + dice roll
    For i = MyPosition To EndPosition
        Call SetPosition(i)
        MyPosition = i                      'basically just setting it so i can use it if needs be
        Delay 0.5
        Text5 = MyPosition                  'just to display position
    Next i

Code:
Private Sub SetPosition(ByVal N As Long)

r = N \ 10

If IsOdd(r) Then
c = 9 - (N Mod 10)
Else
c = N Mod 10
End If

Shape1.Left = (c * 41) + 10
Shape1.Top = 410 - 30 - (2 * 41)
End Sub
 
cheers for the help guys, got it sorted finally, sorry bout all the variables not being explained, was just using this to get my head round the coding side, wasnt too bothered about the actual final product, got couple of months for that :D

but just to clear things up,
N is the position of the counter used to get the column(C) and row (R), thus the lines
Code:
For i = MyPosition To EndPosition
        Call SetPosition(i)
most of the variables are defined in the general declerations as i wanted some of them to be global
 
Back
Top Bottom