-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (41 loc) · 1.3 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
import endMenu
from DraughtsAPI import DraughtsAPI
from GameGUI import GameGUI
from MainMenu import MainMenu
import time
def new_game(punkts):
game = DraughtsAPI()
gameGUI = GameGUI(game)
mainMenu = MainMenu(punkts)
game_type, selectchess = mainMenu.run()
if game_type == "load":
with open("load.txt", "r") as f:
string = f.read()
game.load_game(string)
elif game_type == "AI":
game.AI = True
game.playerDraughts = selectchess
gameGUI.set_start_position()
else:
game.playerDraughts = selectchess
gameGUI.set_start_position()
return game, gameGUI
punkts = [(300, 200, u'Simple Game', (123, 15, 34), (235, 75, 156), 0),
(300, 300, u'Game with AI', (123, 15, 34), (235, 75, 156), 1),
(400, 400, u'Load', (123, 15, 34), (235, 75, 156), 2),
(400, 500, u'Exit', (123, 15, 34), (235, 75, 156), 3)]
game, gameGUI = new_game(punkts)
done = True
newGame = False
while done:
time.sleep(0.05)
if newGame:
game, gameGUI = new_game(punkts)
newGame = False
endgame, gameresult = game.check_end_game()
if endgame:
EndMenu = endMenu.EndMenu()
newGame = EndMenu.run(gameresult)
else:
gameGUI.render()
done = gameGUI.mouse_event_check()