Add a small bomb exploding animation, fixes #31

This commit is contained in:
Yohann D'ANELLO
2020-12-12 16:50:01 +01:00
parent 1986630da1
commit 8608ce346f
3 changed files with 42 additions and 1 deletions

View File

@ -158,6 +158,10 @@ class Bomb(Item):
m.logs.add_message(log_message)
m.entities.remove(self)
# Add sparkles where the bomb exploded.
explosion = Explosion(y=self.y, x=self.x)
self.map.add_entity(explosion)
def save_state(self) -> dict:
"""
Saves the state of the bomb into a dictionary
@ -168,6 +172,26 @@ class Bomb(Item):
return d
class Explosion(Item):
"""
When a bomb explodes, the explosion is displayed.
"""
def __init__(self, *args, **kwargs):
super().__init__(name="explosion", *args, **kwargs)
def act(self, m: Map) -> None:
"""
The explosion instant dies.
"""
m.remove_entity(self)
def hold(self, player: InventoryHolder) -> None:
"""
The player can't hold any explosion.
"""
pass
class Weapon(Item):
"""
Non-throwable items that improve player damage