Changeset 204:687459429550


Ignore:
Timestamp:
Sep 3, 2013, 9:14:48 PM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
rebase_source:
ddfc8de917bf6a22c9d6e24bf3734ef4eaa23acc
Message:

Display interior walls and start working towards drawing them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/area_editor.py

    r199 r204  
    2929from nagslang.options import parse_args
    3030from nagslang.constants import SCREEN
    31 from nagslang.level import Level, POLY_COLORS
     31from nagslang.level import Level, POLY_COLORS, LINE_COLOR
    3232from nagslang.enemies import Enemy
    3333
     
    142142                                 self.point_to_pygame(polygon[-1]),
    143143                                 self.point_to_pygame(endpoint))
     144        for line in self.lines:
     145            pointlist = [self.point_to_pygame(p) for p in line]
     146            pygame.draw.lines(self._surface, LINE_COLOR, False, pointlist, 2)
    144147        return self._surface.copy()
    145148
     
    158161        self._draw_objects = False
    159162        self._draw_enemies = False
     163        self._draw_lines = False
    160164
    161165    def _level_coordinates(self, pos):
     
    208212    def change_poly(self, new_poly):
    209213        self.cur_poly = new_poly
     214        self._draw_lines = False
    210215        if self.cur_poly is not None:
    211216            self.filled_mode = False
     217
     218    def line_mode(self):
     219        self.cur_poly = None
     220        self._draw_lines = True
     221        self.filled_mode = False
    212222
    213223    def key_down(self, ev):
     
    236246            self.cur_poly = None
    237247            self.filled_mode = True
     248            self._draw_lines = False
    238249        else:
    239250            alert('Not all polygons closed, so not filling')
     
    256267    def mouse_down(self, ev):
    257268        if ev.button == 1:
    258             print "Click: %r" % (
    259                 self.level.point_to_pymunk(self._level_coordinates(ev.pos)),)
     269            if self._draw_lines:
     270                pass
     271            else:
     272                print "Click: %r" % (
     273                    self.level.point_to_pymunk(
     274                        self._level_coordinates(ev.pos)),)
    260275        if ev.button == 4:  # Scroll up
    261276            self._move_view((0, -10))
     
    334349        end_poly_but.rect.move_ip(MENU_LEFT, y)
    335350        self.add(end_poly_but)
     351        y += MENU_BUTTON_HEIGHT + MENU_PAD
     352
     353        draw_line = Button("Draw interior wall", self.level_widget.line_mode)
     354        draw_line.rect = button_rect.copy()
     355        draw_line.rect.move_ip(MENU_LEFT, y)
     356        self.add(draw_line)
    336357        y += MENU_BUTTON_HEIGHT + MENU_PAD
    337358
Note: See TracChangeset for help on using the changeset viewer.