Ignore:
Timestamp:
09/07/13 22:32:32 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Children:
610:29d67c51fd33, 617:2070ce83637b
Phase:
public
Rebase:
66303738323865633236373163383830656434646134316239343036646431303330666563373864
Message:

KeyedHatch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/render.py

    r558 r609  
    4848
    4949
    50 class HatchRenderer(Renderer):
     50class HatchRendererMixin(object):
    5151    def draw_hatch_line(self, surface, a, b):
    5252        ai, bi = extend_line(a, b, -2)
     
    5757            surface, pygame.color.THECOLORS['lightblue'], ai, bi, 5)
    5858
    59     def render(self, surface):
     59    def render_hatch(self, surface):
    6060        shape = self.game_object.get_shape()
     61        a = shape.body.local_to_world(shape.a)
     62        b = shape.body.local_to_world(shape.b)
    6163        if self.game_object.puzzler.get_state():
    62             offset = vec_from_angle((shape.b - shape.a).angle, 10)
    63             ai = shape.a + offset
    64             bi = shape.b - offset
    65             self.draw_hatch_line(surface, shape.a, ai)
    66             self.draw_hatch_line(surface, bi, shape.b)
    67         else:
    68             mid = shape.a + (shape.b - shape.a) / 2
    69             self.draw_hatch_line(surface, shape.a, mid)
    70             self.draw_hatch_line(surface, mid, shape.b)
     64            offset = vec_from_angle((b - a).angle, 10)
     65            ai = a + offset
     66            bi = b - offset
     67            self.draw_hatch_line(surface, a, ai)
     68            self.draw_hatch_line(surface, bi, b)
     69        else:
     70            mid = a + (b - a) / 2
     71            self.draw_hatch_line(surface, a, mid)
     72            self.draw_hatch_line(surface, mid, b)
     73
     74
     75class HatchRenderer(Renderer, HatchRendererMixin):
     76    def render(self, surface):
     77        self.render_hatch(surface)
    7178
    7279
     
    95102        self.render_image(surface, self.get_image())
    96103        super(ImageRenderer, self).render(surface)
     104
     105
     106class KeyedHatchRenderer(ImageRenderer, HatchRendererMixin):
     107    def render(self, surface):
     108        self.render_hatch(surface)
     109        if not self.game_object.puzzler.get_state():
     110            self.render_image(surface, self.get_image())
    97111
    98112
Note: See TracChangeset for help on using the changeset viewer.