Esempio n. 1
0
 def render(self, surface, rects=None):
     if not self.visible and rects:
         return
     for i in rects:
         if self.rect.colliderect(i):
             image.push_clip(surface, self.rect.clip(i))
             surface.blit(self.surface, self.rect)
             image.pop_clip(surface)
Esempio n. 2
0
 def render(self, surface, rects, camera_pos=[0,0]):
     x, y = self.rect.topleft
     x -= camera_pos[0]
     y -= camera_pos[1]
     for i in rects:
         image.push_clip(surface, i)
         surface.blit(self.image, (x, y))
         image.pop_clip(surface)
Esempio n. 3
0
 def render(self, surface, rects, camera_pos=(0,0)):
     #only render on the dirty rects!
     x, y = self.rect.topleft
     x -= camera_pos[0]
     y -= camera_pos[1]
     for i in rects:
         image.push_clip(surface, i)
         surface.blit(self.comp_image, (x, y))
         image.pop_clip(surface)
Esempio n. 4
0
    def render(self, surface):
        image.push_clip(surface, self.rect)

        r=pygame.Rect(self.camera_pos,
                      self.rect.size)

        if self.dirty:
            image.push_clip(surface, r)
            surface.fill((255,255,255))
            image.pop_clip(surface)
            self.dirty = False
            for i in self.world.dirty_rects:
                i.dirty_rect = None
            self.world.dirty_rects = []
            for i in self.world.get_tiles_in_area(r) +\
                self.world.get_units_in_area(r):
                i.render(surface, [r], self.camera_pos)
        elif self.world.dirty_rects:
            big = []
            rects = []

            for i in self.world.dirty_rects: #get objects, tiles + units
                rects.append(i.dirty_rect)
                image.push_clip(surface, i.dirty_rect)
                surface.fill((255,255,255))
                image.pop_clip(surface)
                for x in i.get_objects_in_quads():
                    if not x in big:
                        big.append(x)

            big.sort(self.mysort)

            for obj in big:
                obj.render(surface, rects, self.camera_pos)
            for i in self.world.dirty_rects:
                i.dirty_rect = None
            self.world.dirty_rects = []

        image.pop_clip(surface)