def create(self, width, height, zonewidth, zoneheight): "Créer une carte vierge" assert width > 0 assert height > 0 assert zonewidth > 0 assert zoneheight > 0 # resize zones and the map widget Zone.WIDTH = zonewidth Zone.HEIGHT = zoneheight self.resize(Zone.WIDTH, Zone.HEIGHT) # build tile-items at first load if not self.isEnabled(): self.build_tiles() self.setEnabled(True) self.set_cursor_visible(True) self.width = width self.height = height del self.zones[:] for i in xrange(width * height): zone = Zone(self) zone.fill_with_tile(0) self.zones.append(zone) self.filename = None self.set_current_zone(0)
def add_column(self, where, tile_id): assert where >= 0 and where <= self.width for i in xrange(where, len(self.zones) + self.height, self.width + 1): zone = Zone(self) zone.fill_with_tile(tile_id) self.zones.insert(i, zone) self.width += 1 self.set_current_zone(0)
def add_line(self, where, tile_id): assert where >= 0 and where <= self.height for i in xrange(self.width): zone = Zone(self) zone.fill_with_tile(tile_id) self.zones.insert(self.width * where, zone) self.height += 1 self.set_current_zone(0)