Esempio n. 1
0
class Game(object):
    def __init__(self):
        self._ge = GameEngine()
        self._ds = DamageSystem(self._ge)
        self._world = None

    def setup_world(self):
        self._world = World(self._ge)

        player = Character(self._ge, "Player1")
        self._world.add_actor(player)

        hit_event = Event(self._ge, "HitPlayerEvent", 2000, self.event_hit_character, player)
        self._world.add_event(hit_event)

        poison_hit_event = Event(
            self._ge, "HitPlayerWithPoisonEvent", 4000, self.event_hit_character_with_poison, player
        )
        self._world.add_event(poison_hit_event)

    def start(self):
        self.setup_world()

        while True:
            self.game_loop()

    def game_loop(self):
        self._world.tick()

    def event_hit_character(self, character):
        damage = DamageOnHit(50, DamageType.normal)
        self._ds.apply_damage(character, damage)

    def event_hit_character_with_poison(self, character):
        damage = DamageOverTime(self._ge, self._ds, 50, DamageType.poison, duration=10000, interval=500)
        character.add_damage_over_time(damage)
Esempio n. 2
0
 def __init__(self):
     self._ge = GameEngine()
     self._ds = DamageSystem(self._ge)
     self._world = None