Hey all, I have been working on this maze game for my introduction to programing class. I have run into a problem. I have my picture box which is the cursor start at location 32,32. When I click any of my buttons it moves the picture box to 0,0. from there everything seems to work but I want to have it start at 32,32. Here is my code.

Module GlobalVariable

    Public value1 As Integer = 12
    Public value2 As Integer = 12
    Public map As Integer(,) = New Integer(0 To value1, 0 To value2) {}
    Public AXval, AYval As Integer
    Public pix As Integer = 32
    Public NXval, NYval As Integer
    Public x As Point
    Public A As Point

    

End Module

Public Class Form1
    Private Sub form_load()
        'declare the walls of the maze
        map(0, 0) = 0
        map(0, 1) = 0
        map(0, 2) = 0
        map(0, 3) = 0
        map(0, 4) = 0
        map(0, 5) = 0
        map(0, 6) = 0
        map(0, 7) = 0
        map(0, 8) = 0
        map(0, 9) = 0
        map(0, 10) = 0
        map(0, 11) = 0
        map(0, 12) = 0

        map(1, 0) = 0
        map(1, 1) = 1
        map(1, 2) = 0
        map(1, 3) = 1
        map(1, 4) = 0
        map(1, 5) = 1
        map(1, 6) = 1
        map(1, 7) = 1
        map(1, 8) = 0
        map(1, 9) = 0
        map(1, 10) = 1
        map(1, 11) = 0
        map(1, 12) = 0

        map(2, 0) = 0
        map(2, 1) = 1
        map(2, 2) = 1
        map(2, 3) = 1
        map(2, 4) = 1
        map(2, 5) = 1
        map(2, 6) = 0
        map(2, 7) = 1
        map(2, 8) = 1
        map(2, 9) = 0
        map(2, 10) = 1
        map(2, 11) = 1
        map(2, 12) = 0

        map(3, 0) = 0
        map(3, 1) = 1
        map(3, 2) = 0
        map(3, 3) = 0
        map(3, 4) = 1
        map(3, 5) = 0
        map(3, 6) = 0
        map(3, 7) = 1
        map(3, 8) = 0
        map(3, 9) = 0
        map(3, 10) = 0
        map(3, 11) = 1
        map(3, 12) = 0

        map(4, 0) = 0
        map(4, 1) = 1
        map(4, 2) = 1
        map(4, 3) = 1
        map(4, 4) = 1
        map(4, 5) = 1
        map(4, 6) = 0
        map(4, 7) = 1
        map(4, 8) = 0
        map(4, 9) = 0
        map(4, 10) = 0
        map(4, 11) = 1
        map(4, 12) = 0

        map(5, 0) = 0
        map(5, 1) = 1
        map(5, 2) = 0
        map(5, 3) = 0
        map(5, 4) = 0
        map(5, 5) = 0
        map(5, 6) = 0
        map(5, 7) = 1
        map(5, 8) = 0
        map(5, 9) = 0
        map(5, 10) = 0
        map(5, 11) = 1
        map(5, 12) = 0

        map(6, 0) = 0
        map(6, 1) = 1
        map(6, 2) = 0
        map(6, 3) = 0
        map(6, 4) = 1
        map(6, 5) = 1
        map(6, 6) = 1
        map(6, 7) = 1
        map(6, 8) = 0
        map(6, 9) = 1
        map(6, 10) = 1
        map(6, 11) = 1
        map(6, 12) = 0

        map(7, 0) = 0
        map(7, 1) = 1
        map(7, 2) = 0
        map(7, 3) = 0
        map(7, 4) = 1
        map(7, 5) = 0
        map(7, 6) = 0
        map(7, 7) = 0
        map(7, 8) = 0
        map(7, 9) = 1
        map(7, 10) = 0
        map(7, 11) = 1
        map(7, 12) = 0

        map(8, 0) = 0
        map(8, 1) = 1
        map(8, 2) = 0
        map(8, 3) = 0
        map(8, 4) = 1
        map(8, 5) = 1
        map(8, 6) = 1
        map(8, 7) = 1
        map(8, 8) = 1
        map(8, 9) = 1
        map(8, 10) = 0
        map(8, 11) = 1
        map(8, 12) = 0

        map(9, 0) = 0
        map(9, 1) = 1
        map(9, 2) = 0
        map(9, 3) = 0
        map(9, 4) = 0
        map(9, 5) = 1
        map(9, 6) = 0
        map(9, 7) = 0
        map(9, 8) = 0
        map(9, 9) = 0
        map(9, 10) = 1
        map(9, 11) = 1
        map(9, 12) = 0

        map(10, 0) = 0
        map(10, 1) = 1
        map(10, 2) = 1
        map(10, 3) = 1
        map(10, 4) = 1
        map(10, 5) = 1
        map(10, 6) = 1
        map(10, 7) = 1
        map(10, 8) = 0
        map(10, 9) = 0
        map(10, 10) = 1
        map(10, 11) = 1
        map(10, 12) = 0

        map(11, 0) = 0
        map(11, 1) = 0
        map(11, 2) = 0
        map(11, 3) = 0
        map(11, 4) = 0
        map(11, 5) = 0
        map(11, 6) = 0
        map(11, 7) = 0
        map(11, 8) = 0
        map(11, 9) = 0
        map(11, 10) = 0
        map(11, 11) = 1
        map(11, 12) = 0

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'load the array 
        Me.form_load()

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightButton.Click
        'declare variables
        Dim xval As Integer = Val(Whitebox.Location.X())
        Dim yval As Integer = Val(Whitebox.Location.Y())

        'set values for variables
        NXval = xval + pix
        AXval = (xval / pix) + 1
        AYval = yval / pix

        If Val(map(AXval, AYval)) = 1 Then x.X = NXval And x.Y = yval
        Whitebox.Location = x
    End Sub

    Private Sub LeftButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeftButton.Click
        Dim xval As Integer = Val(Whitebox.Location.X())
        Dim yval As Integer = Val(Whitebox.Location.Y())

        NXval = xval - pix
        AXval = (xval / pix) - 1
        AYval = yval / pix

        If Val(map(AXval, AYval)) = 1 Then x.X = NXval _
        And x.Y = yval
        Whitebox.Location = x
    End Sub

    Private Sub DownButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownButton.Click
        'declare variables
        Dim xval As Integer = Val(Whitebox.Location.X())
        Dim yval As Integer = Val(Whitebox.Location.Y())

        'set values for variables

        NYval = yval + pix
        AXval = (xval / pix)
        AYval = (yval / pix) + 1

        If Val(map(AXval, AYval)) = 1 Then x.Y = NYVal And x.X = xval
        Whitebox.Location = x
    End Sub

    Private Sub UpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpButton.Click
        'declare variables
        Dim xval As Integer = Val(Whitebox.Location.X())
        Dim yval As Integer = Val(Whitebox.Location.Y())

        'set values for variables

        NYval = yval - pix
        AXval = (xval / pix)
        AYval = (yval / pix) - 1

        If Val(map(AXval, AYval)) = 1 Then x.Y = NYval And x.X = xval
        Whitebox.Location = x
    End Sub
End Class

Here is a link to a picture of the maze. http://i122.photobucket.com/albums/o251/DZSlasher/Maze.jpg

Hi,

In Form_Load, just write this :
(I guess "Whitebox", is the name of your Picturebox)
Whitebox.Location.X() =32
Whitebox.Location.Y() =32


OR

PictureBox1.Left = 32
PictureBox1.Top = 32

Regards
Veena

Hi,

In Form_Load, just write this :
(I guess "Whitebox", is the name of your Picturebox)
Whitebox.Location.X() =32
Whitebox.Location.Y() =32


OR

PictureBox1.Left = 32
PictureBox1.Top = 32

Regards
Veena

Veena,

I tired the second one that you posted but it did not work. The first on that you posted, just give me an error. I appreciate the try.

-DZSlasher-

Hi,

Move the Image and Try to refresh the form:

PictureBox1.Left = 32
PictureBox1.Top = 32
Me.Refresh()

Change Control Names accordingly...

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.