Ignore:
Timestamp:
09/07/13 12:36:09 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Message:

Add Death event to reduce death code duplication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r437 r440  
    99    COLLISION_TYPE_FURNITURE, COLLISION_TYPE_WEREWOLF_ATTACK,
    1010    CMD_TOGGLE_FORM, CMD_ACTION)
    11 from nagslang.events import ScreenChange, DoorEvent, QuitEvent
     11from nagslang.events import ScreenChange, DoorEvent, QuitEvent, DeathEvent
    1212from nagslang.level import Level
    1313from nagslang.screens.base import Screen
     
    166166                    QuitEvent.post()
    167167                    return
    168                 room, pos = self.game_starting_point
    169                 self.world.load()
    170                 self.world.deaths += 1
    171                 ScreenChange.post(room)
    172                 self.protagonist.set_position(pos)
    173                 self._disable_render = True
     168                self.protagonist.die()
    174169                return
    175170            cmd_key = self.keys.get_command_key(ev.key)
     
    188183            # else we're teleporting within the screen, and just the
    189184            # position change is enough
     185        elif DeathEvent.matches(ev):
     186            self._disable_render = True
     187            self.world.load()
     188            self.world.deaths += 1
     189            level, pos = Level.game_starting_point()
     190            self.protagonist.set_position(pos)
     191            ScreenChange.post(level)
     192
    190193        self.keys.handle_event(ev)
    191194
Note: See TracChangeset for help on using the changeset viewer.