I ran up against the limit of the amount of items I could put into a single array... I also ran into the limit of the number of line continuation characters I was able to use... So I had to break this function into two arrays. I really hate that I had to use two arrays, but it does work. Does anyone have any suggestions how I could tighten this code up? Maybe take out the "insert character into a cell" step and just jump right to the color?...
Have fun
Sub Why_Not_Zoidberg()
Dim Inx As Long
Dim i As Long
Dim j As Long
Dim x As Long
Dim A1() As Variant
Dim A2() As Variant
Dim Rng1 As Range
Application.ScreenUpdating = False
A01 = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2)
x = 0
For i = 1 To 24 'Rows
For j = 1 To 64 'Columns
ActiveSheet.Cells(i, j).Select
With Selection
.Value = A01(x)
End With
x = x + 1
Next j
Next i
x = 0
For i = 25 To 48 'Rows
For j = 1 To 64 'Columns
ActiveSheet.Cells(i, j).Select
With Selection
.Value = A02(x)
End With
x = x + 1
Next j
Next i
'SET RANGE
Set Rng1 = Range("A1:BN48")
ActiveSheet.Range("A1").Select
'Add Colors
For i = 1 To Rng1.Rows.Count
For j = 1 To Rng1.Columns.Count
Select Case Rng1.Cells(i, j).Value
Case 3
Rng1.Cells(i, j).Interior.Color = RGB(253, 3, 74)
Case 2
Rng1.Cells(i, j).Interior.Color = RGB(255, 255, 255)
Case 1
Rng1.Cells(i, j).Interior.Color = RGB(1, 1, 1)
Case 14
Rng1.Cells(i, j).Interior.Color = RGB(0, 153, 153)
End Select
'For k = 1 To 10000: Next k, adds a delay to animate
Next j
Next i
With Rng1
.ColumnWidth = 2
.RowHeight = 14.25
.ClearContents
End With
Application.ScreenUpdating = True
End Sub
Your data is highly compressible, is a shame not to make use of it!
Solving your question in a straight way, you may Split a long composed string:
Dim sa As String
sa = "2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2"
sa = sa & " " & "2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 3"
'
' ...
'
sa = sa & " " & "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2"
a = Split(sa)
Your array will be a string array, but arithmetic is not a problem in VBA.
Alternativelly, you could pack your data (4 bit). Example:
'0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 2 2 2 2 ...
Array(&H01234567, &H89ABCDEF, &H11112222, ...)
This way you could extract your data with little bit manipulation.
But really think about compression!
I am going to offer a different approach to this problem.
Create a text file with the values you want to set, arranged by rows and separated by commas (see .csv file format). For example use this pastebin file.
Read the file row by row, parse each line into an array of strings, convert the strings into numbers and use the entire array to set the values of each row on the worksheet.
Apply conditional formatting to the worksheet to display the correct colors based on the values
For Example:
Dim rng_1 As Range
Set rng_1 = Range("M26")
Dim fs As TextStream, txt_row As Variant
Dim val_row() As Variant
Dim n As Integer, i As Integer, j As Integer
Set fs = fso.OpenTextFile("data.csv", ForReading, False)
j = 0
While Not fs.AtEndOfStream
' Read a line of text and split into array of strings
text_row = Strings.Split(fs.ReadLine, ",")
'Need to convert text values into numeric type
n = UBound(text_row) + 1
ReDim val_row(0 To n - 1)
For i = 1 To n
val_row(i - 1) = Val(text_row(i - 1))
Next i
' Write values of entire row onto worksheet
rng_1.Offset(j, 0).Resize(1, n).Value = val_row
' index the row
j = j + 1
Wend
fs.Close
PS. There is rarely a case where .Select and Selection are needed. It is far easier and more robust to read/write directly from range references with the Range() object. In fact, avoid using .Cells() also and use named range references together with .Offset() and .Resize(). For example
Dim A() as Variant
A = Range("my_table").Resize(10,10).Value
A(1,1) = 1 - A(1,2)*A(2,1)
Range("my_table").Resize(10,10).Value = A
I'm making a 2D platformer in Flash for a project, and everything's going swimmingly! It's been easy sailing up until I realize the assignment says to use 2 levels, and the only way I have done levels is via adding them as classes, while this project is using arrays.
I started using URLLoader to plop the levels in .txt files, but even then the example code I've been following only shows how to do this for one level, not for 2+.
Here's the code I'm using for the maps, I can supply more if this isn't sufficient:
public function init()
{
trace("init");
map = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0]]
container = new Sprite();
addChild(container);
tileArray = [Tile0, Tile1, Tile2];
buildMap();
createPlayer();
createWinSpace();
ArrowKeyInput.init(stage);
addEventListener(Event.ENTER_FRAME, update);
}
private function buildMap():void
{
trace("BUILD");
tileMap = [];
for (var i:int = 0; i < map.length; i++)
{
var row:Array = map[i];
var tileRow:Array = [];
tileMap.push(tileRow);
for (var j:int = 0; j < row.length; j++)
{
var tileNum:int = row[j];
var className:Class = tileArray[tileNum];
var tile:MovieClip = new className();
tile.width = tile.height = TILE_SIZE;
tile.x = TILE_SIZE * j;
tile.y = TILE_SIZE * i;
container.addChild(tile);
tileRow.push(tile);
}
}
}
I appreciate any sort of feedback I can get on this.
If I am understanding you correctly, you are wondering how to make your buildMap function be capable of building multiple maps.
What is important to understand about this issue, is that the map array is what the buildMap function utilizes as data to build the level. So whatever is in the map array defines what tiles will be used for each location on the level. So if you want to have multiple levels, you could define multiple maps as such with each having it's own array :
map_1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0]];
map_2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0]];
Those are your map definitions and you can have as many as you like. I just copied the data for the second map, but you can just create a new level in that definition.
Now, before you call the buildMap() function, just set the value of map to whichever level you wish to build :
map = map_1;
buildMap();
or
map = map_2;
buildMap();
Now, you have other things to think about as if you begin with map_1 and then want to build map_2, you need to remove the tiles that you used to build map_1.
From what I can tell in your code, they are all added to the container sprite. So what you could do is remove all those tiles by adding something like this to the beginning of the buildMap() function :
while (container.numChildren > 0)
{
container.removeChildAt(0);
}
Most likely there are other variables that you will need to reset when loading a new level, but this was just meant to be an example of one way you might manage that, with the very little that I know by looking at your code.