diff --git a/.gitignore b/.gitignore index 85e3751..55402af 100644 --- a/.gitignore +++ b/.gitignore @@ -10,12 +10,6 @@ build /lib __pycache__ -# unimportant files that won't pass clean dir check -build* -docs -.claude -my_games - # images are produced by many tests *.png diff --git a/src/scripts/cos_level.py b/src/scripts/cos_level.py index 4b0f77f..e10cca0 100644 --- a/src/scripts/cos_level.py +++ b/src/scripts/cos_level.py @@ -105,7 +105,9 @@ class Level: self.height = height #self.graph = [(0, 0, width, height)] self.graph = RoomGraph( (0, 0, width, height) ) - self.grid = mcrfpy.Grid(grid_size=(width, height), texture=t, pos=(10, 5), size=(1014, 700)) + # #150 - Create grid with explicit layers for color and tilesprite + self.grid = mcrfpy.Grid(grid_size=(width, height), texture=t, pos=(10, 5), size=(1014, 700), + layers={"color": "color", "tilesprite": "tile"}) self.highlighted = -1 #debug view feature self.walled_rooms = [] # for tracking "hallway rooms" vs "walled rooms" @@ -181,7 +183,8 @@ class Level: # self.grid.at((0, y)).walkable = False self.grid.at((self.width-1, y)).walkable = False - def dig_path(self, start:"Tuple[int, int]", end:"Tuple[int, int]", walkable=True, sprite=None): + def dig_path(self, start:"Tuple[int, int]", end:"Tuple[int, int]", walkable=True, color=None, sprite=None): + #print(f"Digging: {start} -> {end}") # get x1,y1 and x2,y2 coordinates: top left and bottom right points on the rect formed by two random points, one from each of the 2 rooms x1 = min([start[0], end[0]]) x2 = max([start[0], end[0]]) @@ -197,6 +200,8 @@ class Level: try: if walkable: self.grid.at((x, ty)).walkable = walkable + if color: + self.grid.at((x, ty)).color = color if sprite is not None: self.grid.at((x, ty)).tilesprite = sprite except: @@ -205,6 +210,8 @@ class Level: try: if walkable: self.grid.at((tx, y)).walkable = True + if color: + self.grid.at((tx, y)).color = color if sprite is not None: self.grid.at((tx, y)).tilesprite = sprite except: @@ -257,7 +264,7 @@ class Level: if prev_room: start = room_coord(prev_room, margin=2) end = room_coord(room, margin=2) - self.dig_path(start, end) + self.dig_path(start, end, color=(0, 64, 0)) prev_room = room # Tile painting diff --git a/src/scripts/cos_tiles.py b/src/scripts/cos_tiles.py index 0054b54..349fe31 100644 --- a/src/scripts/cos_tiles.py +++ b/src/scripts/cos_tiles.py @@ -147,6 +147,7 @@ def wfc_pass(grid, possibilities=None): grid.at((x, y)).tilesprite = matches[0] else: grid.at((x, y)).tilesprite = -1 + grid.at((x, y)).color = (32 * len(matches), 32 * len(matches), 32 * len(matches)) possibilities[(x,y)] = matches if len(possibilities) == len(old_possibilities):