forked from MasterCash/donkey-kong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemySpawner.py
35 lines (28 loc) · 1.15 KB
/
enemySpawner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
The enemy spawner is responsible for
interfacing between the Donkey Kong player/sprite
and the Game Manager in order to add the correct type
of barrel to the game. As well as the barrels generating a fire sprite
"""
import barrel
from fire import Fire, FireType
import game
class EnemySpawner:
def __init__(self):
self.__game = game.GameManager() # GameManager is a singleton so this works
# Spawns a barrel based on the type given by Donkey Kong.
def spawnBarrel(self, barrelType):
""" Spawns a new barrel """
if barrelType == 1:
self.__game.addEnemy(barrel.Barrel(barrel.BarrelType.NORMAL))
elif barrelType == 2:
self.__game.addEnemy(barrel.Barrel(barrel.BarrelType.FIRE))
elif barrelType == 3:
self.__game.addEnemy(barrel.Barrel(barrel.BarrelType.EXPLOSIVE))
elif barrelType == 4:
self.__game.addEnemy(barrel.Barrel(barrel.BarrelType.GOO))
def spawnFire(self, fireType, x, y):
""" Spawns a fire sprite to TERMINATE Mario once and for all """
print("before")
if fireType == 0:
self.__game.addEnemy(Fire(fireType, x, y))