@jrheard/

roguelike

Python

Starter code for a roguelike project. Find more info at https://blog.jrheard.com/python/roguelike.

fork
loading
Files
  • main.py
  • level.txt
  • roguelib.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import roguelib


def run_game():
    # Call roguelib.load_level() to get a dictionary that represents the running game.
    game = roguelib.load_level('level.txt')

    while True:
        # Draw the game and tell the player how to play it.
        roguelib.clear_screen()
        roguelib.draw_game(game)
        roguelib.print_help_info()

        # Prompt the user for a command.
        user_input = input("> ").strip()

        if user_input in ['q', 'quit']:
            # Quit the game!
            break
        else:
            # Do something else!
            roguelib.process_user_input(game, user_input)


if __name__ == '__main__':
    run_game()