-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (53 loc) · 1.42 KB
/
Copy pathmain.py
File metadata and controls
64 lines (53 loc) · 1.42 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
import pygame
import Menu
import TickTakToe
class Main(object):
def __init__(self):
self.fullscreen = False
self.resolution = (300,300)
self.name = "Tick Tack Toe"
self.exit = False
pygame.init()
pygame.display.set_caption(self.name)
self.screen = pygame.display.set_mode(self.resolution)
self.setup_menu(title=self.name)
self.game = TickTakToe.Game()
def setup_menu(self, title="My Game", image=None):
#Setup menu
self.menu = Menu.EzMenu(
["AI goes First", self.ai_first],
["Player goes First", self.ai_second],
["Quit Game", self.quit_game])
self.menu.set_title(title,(20,50))
#self.menu.set_bgimage('images/bg.jpg')
self.menu.set_highlight_color((0,0,255))
self.menu.set_normal_color((0,0,0))
self.menu.center_at(75,150)
self.main_menu = True
def ai_first(self):
#print "AI goes First"
self.main_menu = False
g.game.main_loop(True)
def ai_second(self):
#print "Options"
self.main_menu = False
g.game.main_loop(False)
def credit_screen(self):
#print "Credits"
self.main_menu = False
def quit_game(self):
self.game.game_over = True
#pygame.quit()
if __name__ =="__main__":
g=Main()
g.screen.fill((255, 255, 255))
#Main Game loop
while(not g.game.game_over):
events = pygame.event.get()
if(g.main_menu):
g.menu.update(events)
g.menu.draw(g.screen, g.game.game_over)
else:
g.game.G_input()
#print "start game"
pygame.display.flip()