Ignore:
Timestamp:
Sep 6, 2013, 1:18:40 PM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
rebase_source:
cdef045667f8713abad3989d5b9c8ffd982d9f69
Message:

Split out tiling into utility function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/level.py

    r346 r348  
    55from nagslang import enemies
    66from nagslang import puzzle
     7from nagslang.utils import tile_surface
    78from nagslang.resources import resources
    89from nagslang.yamlish import load, dump
     
    220221            # We assume we don't change
    221222            return self._surface
    222         self._surface = pygame.surface.Surface((self.x, self.y), pgl.SRCALPHA)
    223         self._surface.fill(pygame.color.THECOLORS['black'])
    224         x_step = self._tile_image.get_rect().width
    225         y_step = self._tile_image.get_rect().height
    226         x_count = self.x // x_step + 1
    227         y_count = self.y / y_step + 1
    228         for x in range(x_count):
    229             for y in range(y_count):
    230                 tile_rect = pygame.rect.Rect(x * x_step, y * y_step,
    231                                              x_step, y_step)
    232                 self._surface.blit(self._tile_image, tile_rect)
     223        self._surface = tile_surface((self.x, self.y), self._tile_image)
    233224        return self._surface
Note: See TracChangeset for help on using the changeset viewer.