- #screen.draw.text("This is level {}".format(self._level_name), (200, 100))
- for tile in self._tiles:
- pos = tile['pos']
- pos = [pos[0] * TILE_SIZE, pos[1] * TILE_SIZE]
- if not 'image' in tile:
- # Skip broken tiles for now
- continue
- screen.blit(tile['image'], pos)
-
- def _load_tile_images(self):
- """Load all the tile images"""
- for tile in self._tiles:
- tile['image'] = getattr(images, tile['base'])
+ for y, row in enumerate(self._tiles):
+ for x, tile in enumerate(row):
+ pos = (x * TILE_SIZE - viewport[0],
+ y * TILE_SIZE - viewport[1])
+ if 'image' not in tile:
+ # Skip broken tiles for now
+ continue
+ if 0 <= pos[0] < WIDTH:
+ if 0 <= pos[1] < HEIGHT:
+ screen.blit(tile['image'], pos)