Solved

10 by 10 board

Posted on 2004-09-26
9
138 Views
Last Modified: 2010-05-02
Hey... I am trying to make a board which is sort of like a maze.  It is 10 by 10 and has some blocks in it preventing you from going through.  It's going to be for a game similar to PacMan.  Now, I have a listbox with all of the squares that either you can or cannot go to (your choice, just tell me when you respond).  Now from this list I will need several things done.  I will need to make those squares be a different color than the rest, it can be painted directly on the form.  Then I will also need two other listboxes to be populated with data of allowable moves... one for FROM and one for TO.  So for example, if the player is on box x and can move to the box to the right of it (which means that box x + 1 is an allowable place for the player to be, and it is adjacent to it and not at the beginning of another row), it will do from.additem x and to.additem x + 1.  It should also allow moving down (x and x + 10 when x < 90), up (x and x - 10 when x > 10), and left (x and x - 1 when the square is NOT at the beginning of a row).  Yeah, thats quite a bit but i think that using a few formulae it shouldn't be that hard.

Thanks for taking your time to read, and if you aren't hitting the back button... thanks even more :)
0
Comment
Question by:cachedVB
  • 6
9 Comments
 
LVL 4

Author Comment

by:cachedVB
ID: 12156780
Will give more points if you ask, but i dont have many more
0
 
LVL 4

Expert Comment

by:learning_t0_pr0gram
ID: 12157013
I made a game kind of like this in C++ ...i used a 2x2 matrix.. like...

Dim Maze(9, 9) As Long, Board As String

Board = "0  0  0  0  0  0  0  0  0  0" & vbcrlf & _
            "0  1  1  1  1  1  1  1  1  0" & vbcrlf & _
            "0  1  0  1  0  0  1  0  1  0" & vbcrlf & _
            "0  1  0  1  0  0  1  0  1  0" & vbcrlf & _
            "0  1  0  1  1  1  1  0  1  0" & vbcrlf & _
            "0  1  0  1  1  1  1  0  1  0" & vbcrlf & _
            "0  1  0  1  0  0  1  0  1  0" & vbcrlf & _
            "0  1  0  1  0  0  1  0  1  0" & vbcrlf & _
            "0  1  1  1  1  1  1  1  1  0" & vbcrlf & _
            "0  0  0  0  0  0  0  0  0  0"

or so, 1 could be where you can go, 0 where you can't... then just assign the board to the matrix (Maze)

Dim Tmp() As String, Tmp2() As String

Tmp() = Split(Board, vbcrlf)

For x = 0 to ubound(Tmp)
  Tmp2() = Split(Tmp(x), "   ")
   For y = 0 to ubound(Tmp2)
     Maze(x, y) = Tmp2(y)
   Next
Next

Then you would just call the next spot for the thing to go, and see if it's a 0 or a 1, if it's a 0, don't go ahead with the move, otherwise go forward...

I just think this is easier than adding all the possible moves to a listbox
0
 
LVL 4

Author Comment

by:cachedVB
ID: 12157047
that wont really help me because i already have simple ai code and it would be best if we can stick to what i wrote above :)
0
 
LVL 4

Author Comment

by:cachedVB
ID: 12157165
Private Sub Form_Load()
Me.Show
For i = 0 To List1.ListCount - 1
For x = 0 To List1.ListCount - 1
'check if can go up
If List1.List(x) = List1.List(i) - 3 Then
listfrom.AddItem List1.List(i)
listto.AddItem List1.List(x)
End If
'checking if can go down
If List1.List(x) = List1.List(i) + 3 Then
listfrom.AddItem List1.List(i)
listto.AddItem List1.List(x)
End If
'checking if can go right
If List1.List(x) = List1.List(i) + 1 And Not Int((List1.List(i) + 1) / 3) = ((List1.List(i) + 1) / 3) Then
listfrom.AddItem List1.List(i)
listto.AddItem List1.List(x)
End If
'checking if can go left
If List1.List(x) = List1.List(i) - 1 And Not Int(List1.List(i) / 3) = (List1.List(i) / 3) Then
listfrom.AddItem List1.List(i)
listto.AddItem List1.List(x)
End If
Next x
Next i
End Sub



well i did the listbox part for you guys, now i just need the coloring.  im SURE this is easy but i dont know how to do it.  Ideally it will be 32 by 32 boxes
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:cachedVB
ID: 12157169
Note: Above I only used a 3 by 3 table, but it should work for 10 by 10 so ignore that
0
 
LVL 4

Author Comment

by:cachedVB
ID: 12157236
I answered my own question... sorry guys.
0
 
LVL 4

Author Comment

by:cachedVB
ID: 12157244
The solution i used for painting the form was actually an array of labels which on form load i made them gain a loop through the listbox to color them
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12202055
Question answered by asker or dialog valuable.
Closed, 125 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms access #TYPE! error on report when no data 4 68
vb6 connector to SQL Server 2 34
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 42
Help me. 3 48
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now