comparison tools/area_editor.py @ 432:ed5ba04d553c

avoid some work
author Neil Muller <drnlmuller@gmail.com>
date Sat, 07 Sep 2013 13:52:34 +0200
parents 275e0b4bd571
children 8cd9828828c0
comparison
equal deleted inserted replaced
431:fef028d65451 432:ed5ba04d553c
148 if draw_cand_line and start_pos and mouse_pos: 148 if draw_cand_line and start_pos and mouse_pos:
149 endpoint = self.snap_to_grid(mouse_pos) 149 endpoint = self.snap_to_grid(mouse_pos)
150 pointlist = [start_pos, 150 pointlist = [start_pos,
151 self.point_to_pygame(endpoint)] 151 self.point_to_pygame(endpoint)]
152 pygame.draw.lines(self._surface, LINE_COLOR, False, pointlist, 1) 152 pygame.draw.lines(self._surface, LINE_COLOR, False, pointlist, 1)
153 return self._surface.copy() 153 return self._surface
154 154
155 def reset_objs(self): 155 def reset_objs(self):
156 # Reset the object state - needed when changing stuff 156 # Reset the object state - needed when changing stuff
157 self.drawables = [] 157 self.drawables = []
158 self.overlay_drawables = [] 158 self.overlay_drawables = []
480 for thing in self.level.drawables: 480 for thing in self.level.drawables:
481 if isinstance(thing, ne.Enemy): 481 if isinstance(thing, ne.Enemy):
482 thing.render(level_surface) 482 thing.render(level_surface)
483 surface_area = pygame.rect.Rect(self.pos, SCREEN) 483 surface_area = pygame.rect.Rect(self.pos, SCREEN)
484 zoomed_surface = level_surface.copy() 484 zoomed_surface = level_surface.copy()
485 zoomed_surface = pygame.transform.scale( 485 if self._zoom_factor != 1:
486 level_surface, 486 zoomed_surface = pygame.transform.scale(
487 (int(level_surface.get_width() / self._zoom_factor), 487 level_surface,
488 int(level_surface.get_height() / self._zoom_factor))) 488 (int(level_surface.get_width() / self._zoom_factor),
489 int(level_surface.get_height() / self._zoom_factor)))
489 surface.blit(zoomed_surface, (0, 0), surface_area) 490 surface.blit(zoomed_surface, (0, 0), surface_area)
490 491
491 def change_poly(self, new_poly): 492 def change_poly(self, new_poly):
492 self.cur_poly = new_poly 493 self.cur_poly = new_poly
493 self._draw_lines = False 494 self._draw_lines = False