One I'm just curious as to who does and two I have questions every so often and online help doesnt help at all, and the MSDN is a little too confusing sometimes(Ive self taught myself everything I know)
When I need something new I havent used before, I find out how to do it, but every so often I stumble across something I need that I dont really know how to set up.
Such as matrices, Ive seen plenty of tutorials but none of them explains the step by step things I have to do to use them, I believe I knew how to use them way back when but have forgotten, and nothing I see rings a bell so I may not have ever actually used them.
I need a 65x65 matrix for my RPGM1 map-maker(plus a few other games Im working on that will make things a LOT easier), and I need an easy way of inserting all 4,225 tiles codes that are on a map into the matrix...nesting For()/Next's to "read" them would be easy, I can do that without a problem, the problem is finding out how to insert all 4225 values into the matrix without using up too much coding/time.
The first grid I need to map can be found here (http://pavilionboards.com/forum/showthread.php?t=16683).
Thats where Im going to have problems, I'm going to have so many loops to just create a grid it wont be funny, thats why I was initially using string variables, like this:
a1$ = "19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19"
a2$ = "19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19"
a3$ = "19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19"
etc...
and then calling them up with this:
For zz = 0 To 1040 Step 16 'Icons are 16 pixels wide
For x = 1 To 1041 Step 3 'Beginning of next number is every 3 characters in string
s$ = Mid$(a1, x, 2)
DrawMap
Next
Next
Public Sub DrawMap
If s$ = "01" Then PaintPicture b1.Picture, x * 5 + 1, zz
If s$ = "02" Then PaintPicture b2.Picture, x * 5 + 1, zz
If s$ = "03" Then PaintPicture b3.Picture, x * 5 + 1, zz
If s$ = "04" Then PaintPicture b4.Picture, x * 5 + 1, zz
If s$ = "05" Then PaintPicture b5.Picture, x * 5 + 1, zz
If s$ = "06" Then PaintPicture b6.Picture, x * 5 + 1, zz
If s$ = "07" Then PaintPicture b7.Picture, x * 5 + 1, zz
If s$ = "08" Then PaintPicture b8.Picture, x * 5 + 1, zz
If s$ = "09" Then PaintPicture b9.Picture, x * 5 + 1, zz
If s$ = "10" Then PaintPicture b10.Picture, x * 5 + 1, zz
If s$ = "11" Then PaintPicture b11.Picture, x * 5 + 1, zz
If s$ = "12" Then PaintPicture b12.Picture, x * 5 + 1, zz
If s$ = "13" Then PaintPicture b13.Picture, x * 5 + 1, zz
If s$ = "14" Then PaintPicture b14.Picture, x * 5 + 1, zz
If s$ = "15" Then PaintPicture b15.Picture, x * 5 + 1, zz
If s$ = "16" Then PaintPicture b16.Picture, x * 5 + 1, zz
If s$ = "17" Then PaintPicture b17.Picture, x * 5 + 1, zz
If s$ = "18" Then PaintPicture b18.Picture, x * 5 + 1, zz
If s$ = "19" Then PaintPicture b19.Picture, x * 5 + 1, zz
End Sub
But the problem with that is I would need that chunk of code at the top 65 times because Ill have to access a1, a2, a3.. using a Mid$(), and the string part of the Mid$ cant be called up any way other way beside direct input(as seen above), and if I do that it'll return a "Procedure Too Large" error.
The matrix would make drawing it easier, but I need to make the input easier, Id like to use a matrix for it, but I dont know if I'll be able too..
Is there a way to fill an entire matrix row all at once? I know this doesnt work this is just to give you an idea of what Im talking about:
For x=1 to 65
MatrixA(x,1) = "19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19"
Next
Or will I end up nesting all those loops together?
I suppose it would be possible to have the program break strings apart and insert each value automatically into the matrix, kind of like what I did with the first example.
Stormy
03-26-2008, 11:30 PM
Use two For loops:
(I'm using C# syntax, but I'm sure you'll figure it out)
for (int X=0; X<64; X++)
{
for (int Y=0; Y<64; Y++)
{
//Using the variables X and Y to tell you how far along you are you read your input file and put the tile code into another variable called fileInput
MatrixA(X,Y) = fileInput;
}
}
To Read you'd do something similar.
for (int X=0; X<64; X++)
{
for (int Y=0; Y<64; Y++)
{
Switch (MatrixA(X,Y))
{
case "01": PaintPicture b1.Picture, x * 5 + 1, zz
case "02": ...
}
}
A Switch/case block is like a whole bunch of If/Then statements rolled into a neat bundle.
The three parts of the For Loop in C# are as follows: (int X=0) Initialization/Decleration of the loop variable, (X<64) the condition which must be met if the loop is to continue, and (X++) the operation that modifies the loop/counter variable with each iteration of the loop (you could add three or subtract one, or whatever you like).
If that can be done in VB, then there you go!
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.