naprawa spawner.py

This commit is contained in:
XsedoX 2022-03-21 18:39:28 +01:00
parent f7cfb1a22b
commit b60ecf8ed1
2 changed files with 12 additions and 8 deletions

View File

@ -87,11 +87,15 @@ class Game:
logs = Logs()
knight1 = Knight("./resources/textures/knight.png")
knight2 = Knight("./resources/textures/knight.png")
spawn = Spawner(grid, [knight1, knight2], 4, 5, 8, 0)
knight3 = Knight("./resources/textures/knight.png")
knight4 = Knight("./resources/textures/knight.png")
spawn = Spawner(grid, [knight1, knight2, knight3, knight4], 4, 5, 8, 0)
spawn.spawn()
knights_list = pygame.sprite.Group()
knights_list.add(knight1)
knights_list.add(knight2)
knights_list.add(knight3)
knights_list.add(knight4)
while running:
self.screen.blit(self.bg, (0, 0))

View File

@ -16,7 +16,7 @@ class Spawner:
coords = []
for row in range(self.pos_row, (self.pos_row + self.width)):
for column in range(self.pos_column, (self.pos_column + self.height)):
if self.grid.grid[row][column].texture_path != ("water.png" or "grass_with_tree.jpg"):
if self.grid.grid[row][column].texture_path != "water.png" and self.grid.grid[row][column].texture_path != "grass_with_tree.jpg":
coords.append([(GRID_CELL_PADDING + GRID_CELL_WIDTH) * column + GRID_CELL_PADDING + 7,
(GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING + 7])