-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (57 loc) · 1.84 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
from graphics import *
from settings import *
from level import Level
from player import Player
class Game:
def __init__(self):
self.screen = GraphWin(f'{GAMENAME}', WIDTH, HEIGHT, autoflush=False)
self.level = Level(self.screen)
# pass
def run(self):
# Game Loop
while True:
self.key = self.screen.checkKey()
self.click = self.screen.checkMouse()
self.level.update(self.key, self.click)
if 'Escape' in self.key:
if self.menu():
break
else:
pass
pass
self.screen.close()
def menu(self):
# Esc Menu
recbg = Rectangle(Point(0, 0), Point(800, 600))
bg = color_rgb(100, 100, 100)
recbg.setFill(bg)
recbg.draw(self.screen)
recEsc = Rectangle(Point(300, 200), Point(500, 250))
recEsc.setFill('Red')
recEsc.draw(self.screen)
recEscCenter = recEsc.getCenter()
escText = Text(recEscCenter, 'Fechar Jogo')
escText.setSize(18)
escText.setStyle('bold')
escText.draw(self.screen)
recCon = Rectangle(Point(300, 300), Point(500, 350))
recCon.setFill('Blue')
recCon.draw(self.screen)
recConCenter = recCon.getCenter()
ConText = Text(recConCenter, 'Continuar')
ConText.setSize(18)
ConText.setStyle('bold')
ConText.draw(self.screen)
a = self.screen.getMouse()
if (300 < a.x < 500) and (200 < a.y < 250):
return True
if (300 < a.x < 500) and (300 < a.y < 350):
recbg.undraw()
recEsc.undraw()
escText.undraw()
recCon.undraw()
ConText.undraw()
return False
if __name__ == '__main__':
exe = Game()
exe.run()