Storing 2D arrays within a 2D array - Python -


I have two 2D arrays, each containing information containing each layer:

  Layer0 = [[information], [information]] layer 1 = [[information], [info]]  

I would like to place these two 2D arrays within another array: However, my program will not display tiles properly. My question is this:

Do store 2D arrays within any other 2D array possible? Thank you.

I have a fixed loop system, which is said to run again via an array and display the tile according to the array content:

  For maplayer: For tiles in array: If tile == 0: Screen. Bleet (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 to repeat through the actual map array For another simple, adding pipes, but PyGame displays the blank screen:

for maplayer: for array in codelayer: for tile in array: if tile == 0: Screen. Bleet (white Tile_dict [0], (Self. X, Stay Tile)) self.tileX = self.tileX + 16 if tile == 1: screen. Bleet (Self-Tile_dict [1], (Self. X, Stay Tile Y)) self.tileX = self.tileX + 16 self.tileX = self.cameraX self.tileY + = 16

Here is the complete method:

  def loadmap (self, map): self.tileX = self.cameraX self.tileY = self.cameraY for map maper: array in merpeiler To: tile in array: if tile == 0: screen. Bluetooth (self.tile_dict [0], (self.tileX, self.tileY) self.tileX = self.tileX + 16 if tile == 1: screen. Bleet (Self Tile _ Dict [1], (Self. X, Stay Tile Y)) self.tileX = self.tileX + 16 self.tileX = self.cameraX self.tileY + = 16  < / Pre> 

Thanks.

I have done the reading with 2D arrays and can actually see that you Why is the array INS needed for any other. I used this code to create an array from a file:

  gameMap = [list (row.rstrip ('\' '' )) Open in the row ('cell 1 .txt')]  

then to read it:

  in the range I (0, lane (gameMap )): For the category x (0, lane (gamemap [ii]): xC = x * 30 y = i * 30 if gameMap [i] [x] == "*": screen. Bleet (wall image, (xC, y)) elif gameMap [I] [x] == ".": Screen Blot (Player image, (XC, Y)) Elife gamemap [i] [x] == "+": If the player directs == "up" or player direction == "": screen. Blith (playerford image, Elife Player Direction == "Right": Screen Blit (Playwriter Image, (AXC, Y)) Alif Player Direction == "Left": Screen Blit (player left image, (ax, Y)) Alif feeding Hi direction == "down" screen. Bleet (Playerdownmage, (AXC, Y)) Alif gamemap [i] [x] == "#": Pajamas Draw Screen, black, (xC, y, 30, 30)) elif gameMap [i] [x] == "=": pygame.draw.rect (screen, red, (xC, y, 30, 30))  

Hope that helps, there is a bit confused about why you should put it in another array.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -