Changeset 511:a98ae2bc4957 for nagslang


Ignore:
Timestamp:
Sep 7, 2013, 5:28:27 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
rebase_source:
d47fcb55e8e60ba15e0832e8ae4235b83ada8418
Message:

Fix slow rendering. \o/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r505 r511  
    9393        self.save_progress()
    9494        sound.play_music("POL-cyber-factory-short.ogg")
     95        self._background = None
     96        self._surface = None
    9597
    9698    def teardown(self):
     
    231233        if self._disable_render:
    232234            return
    233         background = self._level.get_background()
    234         render_rect = self._calc_viewport(background, surface)
    235         #mysurface = background.copy()
    236         mysurface = pygame.surface.Surface(background.get_size())
    237         mysurface.set_clip(render_rect)
    238         mysurface.blit(background, render_rect.topleft, render_rect)
     235        if self._background is None:
     236            bg = self._level.get_background()
     237            self._background = pygame.surface.Surface(bg.get_size())
     238            self._background.blit(bg, (0, 0))
     239            self._surface = pygame.surface.Surface(self._background.get_size())
     240        render_rect = self._calc_viewport(self._surface, surface)
     241        self._surface.set_clip(render_rect)
     242        self._surface.blit(self._background, render_rect.topleft, render_rect)
    239243        for drawable in self._drawables:
    240             drawable.render(mysurface)
    241         surface.blit(mysurface, (0, 0), render_rect)
     244            drawable.render(self._surface)
     245        surface.blit(self._surface, (0, 0), render_rect)
    242246        # Maximum width we allow for overlays
    243         max_width = min(render_rect.width, mysurface.get_width())
     247        max_width = min(render_rect.width, self._surface.get_width())
    244248        for overlay in self._level.overlay_drawables:
    245249            if overlay.is_visible():
Note: See TracChangeset for help on using the changeset viewer.