-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
108 lines (94 loc) · 2.88 KB
/
main.py
File metadata and controls
108 lines (94 loc) · 2.88 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'''
main.py description
goMulti: start the mutliplayer window
goHost: start game as host
goClient: start game as client
goSolo: start game as single player
goHome: start the main screen
this can be directly called to start the main game
'''
import tkinter
import tkinter.font as font
import host
import client
import single
from GameEngine import Game
# go to mutliplayer window
def goMulti(parent=None):
if parent:
parent.destroy()
wnd = tkinter.Tk()
wnd.geometry("500x400")
wnd.title("Fight the Professor!")
mainframe = tkinter.Frame(wnd)
mainframe.pack()
lab = tkinter.Label(
mainframe, text="Choose whether you're a\n host or a client:\n")
lab['font'] = font.Font(size=20)
lab.pack()
btn1 = tkinter.Button(mainframe, text="Play as host",
width=18, height=5, command=lambda: goHost(wnd))
btn1['font'] = font.Font(size=14)
btn1.pack()
btn2 = tkinter.Button(mainframe, text="Play as client",
width=18, height=5, command=lambda: goClient(wnd))
btn2['font'] = font.Font(size=14)
btn2.pack()
wnd.mainloop()
# start game as host
def goHost(parent=None):
if parent:
parent.destroy()
wnd = tkinter.Tk()
wnd.geometry("500x400")
wnd.title("Fight the Professor!")
#wnd.resizable(0, 0)
loginGUIObj = host.loginGUI(wnd)
wnd.mainloop()
# start game as client
def goClient(parent=None):
if parent:
parent.destroy()
wnd = tkinter.Tk()
wnd.geometry("500x400")
wnd.title("Fight the Professor!")
wnd.resizable(0, 0)
loginGUIObj = client.loginGUI(wnd)
wnd.mainloop()
# start game as single player
def goSolo(parent=None):
if parent:
parent.destroy()
wnd = tkinter.Tk()
wnd.geometry("800x600")
wnd.title("Fight the Professor!")
wnd.resizable(0, 0)
game = Game('human', 'AI1', 'AI2')
singleGUIObj = single.singleGUI(game)
wnd.mainloop()
# open the main window
def goHome(parent=None):
if parent:
parent.destroy()
wnd = tkinter.Tk()
wnd.geometry("500x400")
wnd.title("Fight the Professor!")
mainframe = tkinter.Frame(wnd)
mainframe.pack()
titleLab = tkinter.Label(mainframe, text="Fight the Professor!")
titleLab['font'] = font.Font(size=24, weight='bold', slant='italic')
titleLab.pack()
lab = tkinter.Label(mainframe, text="Choose the game mode:\n")
lab['font'] = font.Font(size=20)
lab.pack()
btn1 = tkinter.Button(mainframe, text="Multiplayer",
height=5, width=15, command=lambda: goMulti(wnd))
btn1['font'] = font.Font(size=14)
btn1.pack()
btn2 = tkinter.Button(mainframe, text="Single Player",
height=5, width=15, command=lambda: goSolo(wnd))
btn2['font'] = font.Font(size=14)
btn2.pack()
wnd.mainloop()
if __name__ == '__main__':
goHome()