Snakes and Ladders Program. Problem with code.

Netto

Member
Joined
Jan 7, 2008
Messages
8
Programming Experience
Beginner
Hi guys,

I'm having a little problem with some code for a snakes and ladders problem.

The problem is with this line - EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j)).

VB.net says that the problem is Parameter must be positive and < Height.
Parameter name: y

I can't figure out how to fix this, so any help would be appreciated.

I'm a complete novice when it comes to programming but here is my code for the specific problem -

VB.NET:
Public Sub MovePlayer(ByVal Draw As Boolean)
        Dim L As Integer
        Dim T As Integer
        Dim BN As Integer

        BN = CInt(bitmap(P).Tag) - 1

        L = (BN Mod 10) * 50
        T = Int(BN / 10) * 50

        If Int(BN / 10) / 2 <> Int(Int(BN / 10) / 2) Then
            L = PicBoard.Width - L - 50
        End If
        T = PicBoard.Height + T

        If P = 0 Then
            T = T + 20
        ElseIf P = 1 Then
            L = L - 30
            T = T + 20
        ElseIf P = 2 Then
            L = L - 30
            T = T + 50
        ElseIf P = 3 Then
            T = T + 50
        End If

        Dim i As Integer
        Dim j As Integer

        If Draw Then
            For i = 0 To EmptyBitmap(P).Width + 1
                For j = 0 To EmptyBitmap(P).Height - 1
                    EmptyBitmap(P).SetPixel(i, j, BoardBitmap.GetPixel(L + i, T + j))
                Next j
            Next
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(bitmap(P), L, T, bitmap(P).Width, bitmap(P).Height)
        Else
            Player(P) = PicBoard.CreateGraphics()
            Player(P).DrawImage(EmptyBitmap(P), L, T, EmptyBitmap(P).Width, EmptyBitmap(P).Height)
        End If
        Player(P).Dispose()
    End Sub


Thanks in advance.
 
Last edited by a moderator:
Excellent it works. Thanks very much. I should be able to handle it from here. You have no idea how much I appreciate it.

Thanks again.
D.
 
Back
Top