-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
80 lines (61 loc) · 1.82 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import sys
import pygame
from src.menu import Menu
from src.player import Player
from src.builder import Builder
from src.selector import Selector
from src.settings import context
from src.textbox import TextBox
pygame.init()
screen = pygame.display.set_mode(context.screen_size, pygame.RESIZABLE)
pygame.display.set_caption("Taiji maker")
icon = pygame.image.load("resource/icon/icon.png")
pygame.display.set_icon(icon)
def end(*_):
pygame.quit()
sys.exit()
def main(*_):
menu = Menu(screen)
while True:
result_menu = menu.run()
if result_menu is not None:
return result_menu
def select(*_):
selector = Selector(screen, play)
while True:
result_selector = selector.run()
if result_selector is not None:
return result_selector
def play(file_name=None, *_):
player = Player(screen, file_name)
while True:
result_main = player.run()
if result_main is not None:
return result_main
def new(*_):
text_box = TextBox(screen, "Enter level name", make, ".tj", True)
while True:
result_text_box = text_box.run()
if result_text_box is not None:
return result_text_box
def load(*_):
selector = Selector(screen, make, False)
while True:
result_selector = selector.run()
if result_selector is not None:
return result_selector
def make(file_name="", new_file=True, *_):
builder = Builder(screen, file_name, new_file)
while True:
result_builder = builder.run()
if result_builder is not None:
return result_builder
if __name__ == "__main__":
scene = main
args = ()
while True:
result = scene(*args)
if type(result) == tuple:
scene, *args = result
else:
scene, args = result, ()