Mercurial > nagslang
changeset 425:1a85044f81a8
Safer color access
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 07 Sep 2013 13:34:01 +0200 |
parents | a64d894aa1bd |
children | 275e0b4bd571 6bbb0ac87acc |
files | nagslang/level.py tools/area_editor.py |
diffstat | 2 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/nagslang/level.py Sat Sep 07 13:30:06 2013 +0200 +++ b/nagslang/level.py Sat Sep 07 13:34:01 2013 +0200 @@ -18,6 +18,8 @@ 4: pygame.color.THECOLORS['blue'], 5: pygame.color.THECOLORS['lightblue'], 6: pygame.color.THECOLORS['magenta'], + 7: pygame.color.THECOLORS['lightgreen'], + 8: pygame.color.THECOLORS['grey'], } @@ -185,7 +187,7 @@ def _draw_walls(self): for index, polygon in self.polygons.items(): - color = POLY_COLORS[index] + color = POLY_COLORS.get(index, pygame.color.THECOLORS['black']) if len(polygon) > 1: pointlist = [self.point_to_pygame(p) for p in polygon] pygame.draw.lines(self._surface, color, False, pointlist, 2)
--- a/tools/area_editor.py Sat Sep 07 13:30:06 2013 +0200 +++ b/tools/area_editor.py Sat Sep 07 13:34:01 2013 +0200 @@ -121,7 +121,7 @@ if filled: self._draw_exterior(True) for index, polygon in self.polygons.items(): - color = POLY_COLORS[index] + color = POLY_COLORS.get(index, pygame.color.THECOLORS['black']) if move_point_mode and index == self._move_poly: pointlist = [p for p in polygon] pointlist = [self.point_to_pygame(p) if p != move_point else