2021-03-14 22:43:26 +01:00
|
|
|
from survival.image import Image
|
2021-03-14 17:12:11 +01:00
|
|
|
from survival.tile import Tile
|
|
|
|
|
|
|
|
|
|
|
|
class TileLayer:
|
|
|
|
def __init__(self, width, height):
|
|
|
|
self.width = width
|
|
|
|
self.height = height
|
|
|
|
self.tiles = [[Tile() for x in range(self.width)] for y in range(self.height)]
|
2021-03-14 22:43:26 +01:00
|
|
|
self.image = Image('atlas.png')
|
2021-03-14 17:12:11 +01:00
|
|
|
|
2021-03-15 13:31:25 +01:00
|
|
|
def draw(self, camera):
|
2021-03-14 17:12:11 +01:00
|
|
|
for y in range(self.height):
|
|
|
|
for x in range(self.width):
|
2021-03-14 22:43:26 +01:00
|
|
|
self.image.pos = (x*32, y*32)
|
|
|
|
self.image.origin = self.tiles[y][x].origin
|
2021-03-15 13:31:25 +01:00
|
|
|
camera.draw(self.image)
|