Changeset 285:ef4f6375c0b5


Ignore:
Timestamp:
Sep 5, 2013, 2:34:17 PM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Children:
286:248b8fdb160c, 288:e2cf46a4eeaf
Message:

Basic death

Location:
nagslang
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/engine.py

    r276 r285  
    77from nagslang.screens.menu import MenuScreen
    88from nagslang.screens.area import AreaScreen
     9from nagslang.screens.playerdied import PlayerDiedScreen
    910from nagslang.events import ScreenChange
    1011from nagslang.world import World
     
    2122        self._screens = {
    2223            'menu': MenuScreen,
     24            'dead': PlayerDiedScreen,
    2325            'level1': AreaScreen,
    2426            'level2': AreaScreen,
  • nagslang/protagonist.py

    r281 r285  
    1212from nagslang.mutators import FLIP_H
    1313from nagslang.resources import resources
     14from nagslang.events import ScreenChange
    1415
    1516
     
    9293        self.physicser.set_space(new_space)
    9394        self.physicser.add_to_space()
     95
     96    def reset(self):
     97        self.health_level = 100
     98        self.is_moving = False
     99
     100        self.go_human()
    94101
    95102    def _make_renderer(self):
     
    272279        return self.health_level
    273280
     281    def die(self):
     282        # Handle player death - may be called due to other reasons
     283        # than zero health
     284        ScreenChange.post('dead')
     285
    274286    def lose_health(self, amount):
    275287        if self.in_human_form():
     
    277289        else:
    278290            self.health_level -= amount / WEREWOLF_SOAK_FACTOR
    279         if self.health_level < PROTAGONIST_HEALTH_MIN_LEVEL:
    280             self.health_level = PROTAGONIST_HEALTH_MIN_LEVEL
     291        if self.health_level <= PROTAGONIST_HEALTH_MIN_LEVEL:
     292            self.die()
    281293
    282294    def gain_health(self, amount):
Note: See TracChangeset for help on using the changeset viewer.