if dg.dungeon[r][c].get_ch() == "#":
            random_board.place_item(Wall(model=Sprites.WALL), r, c)
        elif dg.dungeon[r][c].get_ch() == "+":
            random_board.place_item(Door(model=Sprites.DOOR), r, c)
        elif dg.dungeon[r][c].get_ch() == ".":
            potential_starting_position.append([r, c])
random_board.player_starting_position = choice(potential_starting_position)
print("done")
print(f"starting position chosen: {random_board.player_starting_position}")

# dg.print_map()
# random_board.display()
input("New random dungeon generated. Next?")

g = Game()
g.enable_partial_display = True
# g.load_board('/home/arnaud/Code/Games/hgl-editor/Large_Dungeon.json', 1)
g.player = Player(model=Sprites.MAGE)
g.add_board(1, random_board)
g.change_level(1)

key = None
viewport = [10, 10]
g.partial_display_viewport = viewport
while True:
    if key == "Q":
        break
    elif key == "S":
        g.save_board(1, f"random-dungeon-{randrange(1000,9999)}.json")
    elif key == "1":
        viewport = [10, 10]
Esempio n. 2
0
    else:
        print("No pre-existing map found.")
    print("n - create a new map")
    print("q - Quit the editor")
    choice = input("Enter your choice (and hit ENTER): ")
    if choice == "q":
        print("Good Bye!")
        exit()
    elif choice == "n":
        create_board_wizard()
        break
    elif choice.isdigit() and int(choice) < len(hmaps):
        current_file = hmaps[int(choice)]
        board = game.load_board(hmaps[int(choice)], 1)
        if board.size[0] >= viewport_height or board.size[1] >= viewport_width:
            game.enable_partial_display = True
            game.partial_display_viewport = [viewport_height, viewport_width]
        else:
            game.enable_partial_display = False
        break

game.change_level(1)

if len(game.object_library) > 0:
    object_history += game.object_library
    for i in game.object_library:
        if i not in game.config("settings")["object_library"]:
            game.config("settings")["object_library"].append(i)

# Build the menus
i = 0