/
main.py
37 lines (31 loc) · 1.05 KB
/
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
28
29
30
31
32
33
34
35
36
37
import libtcodpy as tcod
import settings
from menu import menu
from menu import msgbox
from new_game import new_game
from play_game import play_game
settings.init()
if __name__ == "__main__":
img = tcod.image_load('assets/images/menu_background1.png')
while not tcod.console_is_window_closed():
tcod.image_blit_2x(img, 0, 0, 0)
tcod.console_set_default_foreground(0, tcod.light_yellow)
tcod.console_print_ex(0, settings.SCREEN_WIDTH // 2, settings.SCREEN_HEIGHT // 2 - 4, tcod.BKGND_NONE, tcod.CENTER,
'Legend of the Boner Dome')
tcod.console_print_ex(0, settings.SCREEN_WIDTH // 2, settings.SCREEN_HEIGHT - 2, tcod.BKGND_NONE, tcod.CENTER,
'By Jack Chick')
choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24, new_game=True)
if choice == 0:
game = new_game()
if game is not None:
play_game()
elif choice == 1:
try:
settings.load_game()
except (KeyError) as err:
print("***ERROR: Key not found: " + str(err))
msgbox("No savegame found", 24)
continue
play_game()
elif choice == 2:
break