zmiana rzedow z sprite.Group na pythonowa tablice

This commit is contained in:
XsedoX 2022-04-08 11:24:03 +02:00
parent 37eb63705d
commit 5700cd89c8

View File

@ -28,9 +28,9 @@ class Grid:
podkladka[rzad][kolumna] = 2 podkladka[rzad][kolumna] = 2
else: else:
drzewa = drzewa - 1 drzewa = drzewa - 1
print(podkladka)
for row in range(ROWS): for row in range(ROWS):
self.grid.append(pygame.sprite.Group()) self.grid.append([])
for column in range(COLUMNS): for column in range(COLUMNS):
box_rect = [(GRID_CELL_PADDING + GRID_CELL_WIDTH) * column + GRID_CELL_PADDING + 7, box_rect = [(GRID_CELL_PADDING + GRID_CELL_WIDTH) * column + GRID_CELL_PADDING + 7,
(GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING + 7, (GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING + 7,
@ -57,7 +57,7 @@ class Grid:
else: else:
self.free_fields.append(field) self.free_fields.append(field)
self.grid[row].add(field) self.grid[row].append(pygame.sprite.Group(field))
def update(self, screen): def update(self, screen):
self.draw(screen) self.draw(screen)
@ -72,4 +72,5 @@ class Grid:
pygame.draw.rect(screen, (255, 255, 255), pygame.Rect(5, 5, bg_width, bg_height), 0, BORDER_RADIUS) pygame.draw.rect(screen, (255, 255, 255), pygame.Rect(5, 5, bg_width, bg_height), 0, BORDER_RADIUS)
for fields_row in self.grid: for fields_row in self.grid:
fields_row.draw(screen) for fields in fields_row:
fields.draw(screen)