Ignore:
Timestamp:
09/02/13 11:21:53 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

More consistent debug rendering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/protagonist.py

    r101 r104  
    11import pymunk
    22import pymunk.pygame_util
    3 
    4 import pygame
    53
    64from nagslang.constants import COLLISION_TYPE_PLAYER
     
    86    GameObject, SingleShapePhysicser, FacingImageRenderer)
    97from nagslang.mutators import FLIP_H
    10 from nagslang.options import options
    118from nagslang.resources import resources
    129
     
    5653        self._renderers = {
    5754            self.HUMAN_FORM: FacingImageRenderer(
     55                self._shapes[self.HUMAN_FORM],
    5856                self._get_image('human_1.png'),
    5957                self._get_image('human_1.png', FLIP_H)),
    6058            self.WOLF_FORM: FacingImageRenderer(
     59                self._shapes[self.WOLF_FORM],
    6160                self._get_image('werewolf_1.png'),
    6261                self._get_image('werewolf_1.png', FLIP_H)),
     
    134133            return
    135134        self._body.apply_impulse((dx, dy))
    136 
    137     def render(self, surface):
    138         if options.debug:
    139             # Less general that pymunk.pygame_utils.draw, but also a
    140             # lot less noisy
    141             color = pygame.color.THECOLORS['lightblue']
    142             if hasattr(self._shapes[self.form], 'get_vertices'):
    143                 # polygon bounding box
    144                 points = [pymunk.pygame_util.to_pygame(p, surface)
    145                           for p in self._shapes[self.form].get_vertices()]
    146                 pygame.draw.lines(surface, color, True, points, 2)
    147             else:
    148                 # draw the circle
    149                 centre = pymunk.pygame_util.to_pygame(
    150                     self._shapes[self.form].body.position, surface)
    151                 radius = int(self._shapes[self.form].radius)
    152                 pygame.draw.circle(surface, color, centre, radius, 2)
    153         super(Protagonist, self).render(surface)
Note: See TracChangeset for help on using the changeset viewer.