I have two 2D arrays, each containing information that will display a layer:
layer0 = [[info], [info]]
layer1 = [[info], [info]]
I would like to contain these two 2D-arrays, within yet another array:
map = [[layer0], [layer1]]
However, my program will not display the tiles correctly. My question is: Is it possible to store 2D arrays, within another 2D array? Thank you.
I have a certain loop-system for iterating through said arrays and displaying tiles corresponding to the array content:
for array in maplayer:
for tile in array:
if tile == 0:
screen.blit(self.tile_dict[0], (self.tileX, self.tileY))
self.tileX = self.tileX+16
if tile == 1:
screen.blit(self.tile_dict[1], (self.tileX, self.tileY))
self.tileX = self.tileX+16
self.tileX = self.cameraX
self.tileY += 16
I have tried adding another simple for loop, to iterate through the actual map array, but PyGame displays a blank screen:
for maplayer in map:
for array in maplayer:
for tile in array:
if tile == 0:
screen.blit(self.tile_dict[0], (self.tileX, self.tileY))
self.tileX = self.tileX+16
if tile == 1:
screen.blit(self.tile_dict[1], (self.tileX, self.tileY))
self.tileX = self.tileX+16
self.tileX = self.cameraX
self.tileY += 16
Here is the full method:
def LoadMap(self, map):
self.tileX = self.cameraX
self.tileY = self.cameraY
for maplayer in map:
for array in maplayer:
for tile in array:
if tile == 0:
screen.blit(self.tile_dict[0], (self.tileX, self.tileY))
self.tileX = self.tileX+16
if tile == 1:
screen.blit(self.tile_dict[1], (self.tileX, self.tileY))
self.tileX = self.tileX+16
self.tileX = self.cameraX
self.tileY += 16
Thanks.