Merge pull request 'naprawa spawner.py' (#6) from spawner into master
Reviewed-on: #6
This commit is contained in:
commit
84b17269e3
@ -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))
|
||||
|
@ -16,13 +16,13 @@ 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])
|
||||
|
||||
for obj in self.objs_to_spawn_list:
|
||||
random_tile = random.randint(0, len(coords) - 1)
|
||||
obj.rect.x = coords[random_tile][0]
|
||||
obj.rect.y = coords[random_tile][1]
|
||||
coords.pop(random_tile)
|
||||
obj.update()
|
||||
for obj in self.objs_to_spawn_list:
|
||||
random_tile = random.randint(0, len(coords) - 1)
|
||||
obj.rect.x = coords[random_tile][0]
|
||||
obj.rect.y = coords[random_tile][1]
|
||||
coords.pop(random_tile)
|
||||
obj.update()
|
||||
|
Loading…
Reference in New Issue
Block a user