Compare commits

..

No commits in common. "50eba3314b67b53fac90f8e6f8aea00b878fa3ec" and "726a9cf09d48735da5068c9bd19d02aaf68f202f" have entirely different histories.

3 changed files with 11 additions and 9 deletions

6
.gitignore vendored
View file

@ -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

View file

@ -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

View file

@ -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):