Ignore:
Timestamp:
09/04/13 22:05:17 (8 years ago)
Author:
David Sharpe
Branch:
default
Phase:
public
Rebase:
31393335633036343934613539343831633732306537376531353766323461306632626433323363
Message:

Added collision damage with enemies.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r257 r258  
    55import pymunk.pygame_util
    66
    7 from nagslang.constants import COLLISION_TYPE_PLAYER, CALLBACK_COLLIDERS
     7from nagslang.constants import COLLISION_TYPE_PLAYER, CALLBACK_COLLIDERS, \
     8    COLLISION_TYPE_ENEMY
    89from nagslang.events import ScreenChange, DoorEvent
    910from nagslang.level import Level
     
    8586        gobj = arbiter.shapes[1].physicser.game_object
    8687        result = gobj.collide_with_protagonist(self.protagonist)
     88        if arbiter.shapes[1].collision_type == COLLISION_TYPE_ENEMY:
     89            self.protagonist.lose_health(15)
    8790        # The collision handler must return `True` or `False`. We don't want to
    8891        # accidentally reject collisions from handlers that return `None`, so
     
    190193        super(AreaScreen, self).tick(seconds)
    191194
    192     def render_health_bar(self, surface):
     195    def render_health_bar(self, surface, damage_experienced=None):
    193196        rect = pygame.Rect(50, 500, 110, 50)
     197        if damage_experienced:
     198            health_box_colour = pygame.color.THECOLORS['red']
     199        else:
     200            health_box_colour = pygame.color.THECOLORS['white']
    194201        pygame.draw.rect(surface,  health_box_colour, rect, 0)
    195202        if self.protagonist.in_human_form():
Note: See TracChangeset for help on using the changeset viewer.