Add possibility to define the background color of entities (black in ASCII, white in Unicode)
This commit is contained in:
parent
a8223aab2e
commit
d26b66f337
@ -1,9 +1,19 @@
|
||||
from random import choice
|
||||
|
||||
from ..interfaces import FightingEntity, Map
|
||||
|
||||
|
||||
class Monster(FightingEntity):
|
||||
def act(self, m: Map) -> None:
|
||||
pass
|
||||
"""
|
||||
By default, a monster will move randomly where it is possible
|
||||
And if a player is close to the monster, the monster run on the player.
|
||||
"""
|
||||
# TODO If a player is close, move to the player
|
||||
while True:
|
||||
if choice([self.move_up, self.move_down,
|
||||
self.move_left, self.move_right])():
|
||||
break
|
||||
|
||||
|
||||
class Hedgehog(Monster):
|
||||
|
@ -71,6 +71,7 @@ class Game:
|
||||
self.display_refresh()
|
||||
key = screen.getkey()
|
||||
self.handle_key_pressed(self.translate_key(key))
|
||||
self.map.tick()
|
||||
|
||||
def translate_key(self, key: str) -> KeyValues:
|
||||
"""
|
||||
|
@ -88,6 +88,13 @@ class Map:
|
||||
hedgehog.move(y, x)
|
||||
self.add_entity(hedgehog)
|
||||
|
||||
def tick(self) -> None:
|
||||
"""
|
||||
Trigger all entity events.
|
||||
"""
|
||||
for entity in self.entities:
|
||||
entity.act(self)
|
||||
|
||||
|
||||
class Tile(Enum):
|
||||
EMPTY = auto()
|
||||
|
Loading…
Reference in New Issue
Block a user