Spawn also items

This commit is contained in:
Yohann D'ANELLO
2020-11-11 16:23:27 +01:00
parent d75f4290ff
commit 2b5d82db57
5 changed files with 21 additions and 7 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
from enum import Enum, auto
from math import sqrt
from random import randint
from random import choice, randint
from typing import List
from dungeonbattle.display.texturepack import TexturePack
@ -97,10 +97,9 @@ class Map:
tile = self.tiles[y][x]
if tile.can_walk():
break
from dungeonbattle.entities.monsters import Hedgehog
hedgehog = Hedgehog()
hedgehog.move(y, x)
self.add_entity(hedgehog)
entity = choice(Entity.get_all_entity_classes())()
entity.move(y, x)
self.add_entity(entity)
def tick(self) -> None:
"""
@ -193,6 +192,12 @@ class Entity:
"""
return sqrt(self.distance_squared(other))
@staticmethod
def get_all_entity_classes():
from dungeonbattle.entities.items import Heart, Bomb
from dungeonbattle.entities.monsters import Hedgehog
return [Hedgehog, Heart, Bomb]
class FightingEntity(Entity):
maxhealth: int