Commit ba32ba2e authored by Toast Engineer's avatar Toast Engineer

More intricate maze generation. Should not be focusing on this.

parent e9febe0d
......@@ -105,6 +105,7 @@ class GameState:
def current_level(self, newlevel):
self.world_renderer.change_level(newlevel)
self._current_level = newlevel
self.camera.location = V(1.5, 1.5)
def run_game(self) -> typing.NoReturn:
clock = pygame.time.Clock()
......
......@@ -244,7 +244,10 @@ class WorldRenderer:
print(traceback.format_exc())
continue
rect = scaledsprite.get_rect()
rect.center = screenx, screeny
try:
rect.center = screenx, screeny
except TypeError:
print(screenx, screeny)
self.surf.blit(scaledsprite, rect)
......
import functools
import math
import random
from pathlib import Path
......@@ -167,10 +168,31 @@ class LadderDown(Entity):
gamestate.camera.location = self.prev_ladder.location
print(f"You climb down the ladder to Floor {gamestate.current_level.floor}.")
dfs = lambda x: x[-1]
bfs = lambda x: x[0]
fiftyfifty = lambda x: x[-1] if random.random() < 0.5 else x[0]
seventytwenty = lambda x: x[-1] if random.random() < 0.7 else x[0]
twentyseventy = lambda x: x[-1] if random.random() > 0.7 else x[0]
mid = lambda x: x[len(x)//2]
rand = random.choice
sinlen = lambda x: x[math.floor(math.sin(len(x))*len(x))]
tanlen = lambda x: x[math.floor(math.tan(len(x))*len(x))]
maze_styles = [dfs, bfs, fiftyfifty, seventytwenty, twentyseventy, mid, sinlen]
combos = [functools.partial(
lambda a, b, x: a(x) if random.random()<0.5 else b(x), a, b)
for a in maze_styles for b in maze_styles]
maze_styles.extend(combos)
combos2 = [functools.partial(
lambda a, b, x: a(x) if random.random()<0.5 else b(x), a, b)
for a in combos for b in combos]
maze_styles.extend(combos2)
class World:
def __init__(self, floor = 0):
self.floor = floor
self.map = growing_tree(5 * (floor+1), lambda x: x[-1])
maze_style = dfs if floor <= 1 else random.choice(maze_styles)
loopiness = 0 if floor <= 1 else random.random() / 4
self.map = growing_tree(int(floor/4)+5, maze_style, loopiness)
self.open_locations = list(map(V, numpy.transpose((self.map != True).nonzero())))
#self.adjacent_open_cells = numpy.sum((self.map[0:-3,1:-2], self.map[2:-1, 1:-2], self.map[1:-2, 0:-3], self.map[1:-2, 2:-1]),
# dtype=numpy.int8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment