def _do_split(p_room, p_split_dir, p_config): """ Internal implementation of _split_room in the specified direction. """ room_dims = p_room.dims if p_split_dir == split_types.vertical: span = room_dims.w else: span = room_dims.h split_point = _pick_split_point(span, p_config) if split_point == -1: return None topleft = p_room.topleft dims = p_room.dims first_room = room() #left or top second_room = room() #bottom or right first_room.topleft = point(topleft.x, topleft.y) #remaining properties depend on split direction if p_split_dir == split_types.vertical: first_room.dims = dimensions(split_point, dims.h) second_room.topleft = point(topleft.x + split_point, topleft.y) second_room.dims = dimensions(dims.w - split_point, dims.h) else: first_room.dims = dimensions(dims.w, split_point) second_room.topleft = point(topleft.x, topleft.y + split_point) second_room.dims = dimensions(dims.w, dims.h - split_point) return (first_room, second_room)
def __init__(self): self.topleft = point() self.dims = dimensions() self.offset_left = 0 #offsets from "field" size (determine actual room size) self.offset_right = 0 self.offset_top = 0 self.offset_bottom = 0 self.contents = room_contents()
def __init__(self): self.dims = dimensions() self.min_span = 4 #minimum width/height for any room (after deducting offsets) self.min_offset = 1 #minimum offset for each side self.corridor_min_width = 1 self.corridor_max_width = 4 #min/max width for corridors self.max_depth = 3 #maximum amount of "splits" in the dungeon tree (higher = more, smaller rooms) self.early_stop_chance = 0.1 #chance to stop splitting before reaching max depth. self.early_stop_factor = 2 #factor for early_stop_chance - multiplied with early_stop_chance every level beyond the first #i.e. with a factor of 2 and a chance of 0.1, level 2 has a stop chance of 0.1 * 2 * 2 = 0.4. self.max_attempts = 50 #maximum number of attempts to generate a valid dungeon before quitting
def __init__(self): self.dims = dimensions() self.type = element_type.other self.xp_value = 0 self.name = "NONAME"
def __init__(self): self.topleft = point() self.dims = dimensions()
leafs = p_dungeon.leafs() for leaf in leafs: _add_offset_single(leaf.val, p_config) class map: def __init__(self, p_dims): self.dungeon = bintree() root_room = room() root_room.dims = p_dims self.dungeon.val = root_room self.corridors = [] def gen_corridors(self): pass def generate_tree(self, p_config): _gen_tree_impl(self.dungeon, p_config) _add_offsets(self.dungeon, p_config) def generate(self, p_config): self.generate_tree(p_config) if __name__ == "__main__": random.seed() mymap = map(dimensions(50, 50)) mymap.generate(generator_config()) renderer = render() renderer.render_to_file(mymap, "test.png")