29 lines
716 B
Python
29 lines
716 B
Python
import pygame
|
|
import random
|
|
from settings import *
|
|
from enemy import Enemy
|
|
|
|
|
|
class EnemyManager:
|
|
def __init__(self, world, player):
|
|
self.world = world
|
|
self.player = player
|
|
self.enemies = []
|
|
|
|
# spawn a few enemies to start
|
|
for _ in range(5):
|
|
self.spawn_enemy()
|
|
|
|
def spawn_enemy(self):
|
|
x = random.randint(0, self.world.width * TILE_SIZE)
|
|
y = (SURFACE_LEVEL - 5) * TILE_SIZE
|
|
self.enemies.append(Enemy(x, y))
|
|
|
|
def update(self, dt):
|
|
for enemy in self.enemies:
|
|
enemy.update(dt, self.world, self.player)
|
|
|
|
def draw(self, screen, camera):
|
|
for enemy in self.enemies:
|
|
enemy.draw(screen, camera)
|