Merge pull request 'naprawa spawner.py' (#6) from spawner into master

Reviewed-on: #6
This commit is contained in:
Juliusz Sadowski 2022-03-21 18:43:30 +01:00
commit 84b17269e3
2 changed files with 12 additions and 8 deletions

View File

@ -87,11 +87,15 @@ class Game:
logs = Logs() logs = Logs()
knight1 = Knight("./resources/textures/knight.png") knight1 = Knight("./resources/textures/knight.png")
knight2 = 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() spawn.spawn()
knights_list = pygame.sprite.Group() knights_list = pygame.sprite.Group()
knights_list.add(knight1) knights_list.add(knight1)
knights_list.add(knight2) knights_list.add(knight2)
knights_list.add(knight3)
knights_list.add(knight4)
while running: while running:
self.screen.blit(self.bg, (0, 0)) self.screen.blit(self.bg, (0, 0))

View File

@ -16,7 +16,7 @@ class Spawner:
coords = [] coords = []
for row in range(self.pos_row, (self.pos_row + self.width)): for row in range(self.pos_row, (self.pos_row + self.width)):
for column in range(self.pos_column, (self.pos_column + self.height)): 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, coords.append([(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])