This commit is contained in:
Christian
2024-08-07 16:21:02 +02:00
parent ff8ff04f45
commit ba21a28ec9
7 changed files with 173 additions and 11 deletions

19
Tileset.py Normal file
View File

@@ -0,0 +1,19 @@
import pygame
import Tiletype
import Utils
class TileSet(object):
def __init__(self, image, colorkey, tile_width, tile_height) -> None:
self.image = Utils.load_image(image, colorkey)
self.tile_width = tile_width
self.tile_height = tile_height
self.tile_types = dict()
def add_tile(self, name, start_x, start_y):
self.tile_types[name] = Tiletype.TileType(name, start_x, start_y, self.tile_width, self.tile_height)
def get_tile(self, name):
try:
return self.tile_types[name]
except KeyError:
return None