def draw(self, surface): """ Draw sprite on surface. Returns list of Rect of sprites updated, which can be passed to display.update. """ surface._blits(self._sprites.itervalues()) if self._clear_active: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] for sprite in self._sprites: if sprite in self._sprites_drawn: if self._sprites_drawn[sprite].intersects( self._sprites[sprite].rect): self._sprites_drawn[sprite].union_ip( self._sprites[sprite].rect) else: self.changed_areas.append( rectPool.copy(self._sprites[sprite].rect)) else: self.changed_areas.append( rectPool.copy(self._sprites[sprite].rect)) self.changed_areas.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy( self._sprites[sprite].rect) else: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] self.changed_areas.extend([ rectPool.copy(sprite.rect) for sprite in self._sprites.itervalues() ]) return self.changed_areas
def draw(self, surface): """ Draw sprite on surface in order of addition. """ if self.sort: order_sprite = iter(self.sort) else: keys = self.order.keys() keys.sort() self.sort = [self._sprites[self.order[key]] for key in keys] order_sprite = iter(self.sort) surface._blits(order_sprite) if self._clear_active: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] for sprite in self._sprites: if sprite in self._sprites_drawn: if self._sprites_drawn[sprite].intersects(self._sprites[sprite].rect): self._sprites_drawn[sprite].union_ip(self._sprites[sprite].rect) else: self.changed_areas.append(rectPool.copy(self._sprites[sprite].rect)) else: self.changed_areas.append(rectPool.copy(self._sprites[sprite].rect)) self.changed_areas.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy(self._sprites[sprite].rect) else: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] self.changed_areas.extend([rectPool.copy(sprite.rect) for sprite in self._sprites.itervalues()]) return self.changed_areas
def draw(self, surface): """ Draw sprite on surface. Returns list of Rect of sprites updated, which can be passed to display.update. """ surface._blits(self._sprites.itervalues()) if self._clear_active: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] for sprite in self._sprites: if sprite in self._sprites_drawn: if self._sprites_drawn[sprite].intersects(self._sprites[sprite].rect): self._sprites_drawn[sprite].union_ip(self._sprites[sprite].rect) else: self.changed_areas.append(rectPool.copy(self._sprites[sprite].rect)) else: self.changed_areas.append(rectPool.copy(self._sprites[sprite].rect)) self.changed_areas.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy(self._sprites[sprite].rect) else: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] self.changed_areas.extend([rectPool.copy(sprite.rect) for sprite in self._sprites.itervalues()]) return self.changed_areas
def draw(self, surface): """ Draw sprite on surface. """ surface._blits(self._sprites.itervalues()) if self._clear_active: rectPool.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy(self._sprites[sprite].rect) return None
def draw(self, surface): """ Draw sprite on surface. """ surface._blits(self._sprites.itervalues()) if self._clear_active: rectPool.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy( self._sprites[sprite].rect) return None
def draw(self, surface): """ Draw sprite on surface in order of addition. """ if self.sort: order_sprite = iter(self.sort) else: keys = self.order.keys() keys.sort() self.sort = [self._sprites[self.order[key]] for key in keys] order_sprite = iter(self.sort) surface._blits(order_sprite) if self._clear_active: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] for sprite in self._sprites: if sprite in self._sprites_drawn: if self._sprites_drawn[sprite].intersects( self._sprites[sprite].rect): self._sprites_drawn[sprite].union_ip( self._sprites[sprite].rect) else: self.changed_areas.append( rectPool.copy(self._sprites[sprite].rect)) else: self.changed_areas.append( rectPool.copy(self._sprites[sprite].rect)) self.changed_areas.extend(self._sprites_drawn.itervalues()) self._sprites_drawn.clear() for sprite in self._sprites: self._sprites_drawn[sprite] = rectPool.copy( self._sprites[sprite].rect) else: rectPool.extend(self.changed_areas) self.changed_areas[:] = [] self.changed_areas.extend([ rectPool.copy(sprite.rect) for sprite in self._sprites.itervalues() ]) return self.changed_areas