Changeset 101:93aa745d57ff


Ignore:
Timestamp:
Sep 2, 2013, 10:45:06 AM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Message:

draw protagnist bounding box in debug mode. Redo drawing logic to avoid pymunk noise

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/protagonist.py

    r94 r101  
    11import pymunk
    22import pymunk.pygame_util
     3
     4import pygame
    35
    46from nagslang.constants import COLLISION_TYPE_PLAYER
     
    68    GameObject, SingleShapePhysicser, FacingImageRenderer)
    79from nagslang.mutators import FLIP_H
     10from nagslang.options import options
    811from nagslang.resources import resources
    912
     
    133136
    134137    def render(self, surface):
    135         # Uncomment to draw pymunk shape as well:
    136         # pymunk.pygame_util.draw(surface, self._shapes[self.form])
     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)
    137153        super(Protagonist, self).render(surface)
Note: See TracChangeset for help on using the changeset viewer.