-
Notifications
You must be signed in to change notification settings - Fork 0
/
minesweapper.py
51 lines (43 loc) · 1.33 KB
/
minesweapper.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
from Cell import Cell
from Grid import Grid
from Renderer import Renderer
import pygame as pg
# здесь определяются константы, классы и функции
pg.init()
FPS = 60
BLACK = (0, 0, 0)
cFont = pg.font.SysFont('arial', 28)
def main():
grid = Grid(25, 15, 50, True)
cScreen = pg.display.set_mode((960, 540), pg.RESIZABLE)
while True:
run(grid, cScreen)
def run(grid, cScreen):
gui_renderer = Renderer(cScreen, grid)
while True:
# gui_renderer.clock.tick(FPS)
# цикл обработки событий
event_list = pg.event.get()
if event_list:
for i in event_list:
# события выхода
if i.type == pg.QUIT:
exit()
# ЛКМ
if i.type == pg.MOUSEBUTTONDOWN:
if i.button == 1:
gui_renderer.show_cell(coords=i.pos)
elif i.button == 3:
exit()
else:
pass
gui_renderer.draw_grid()
pg.display.update()
if gui_renderer.grid.isFail():
print('You lose!')
exit()
if gui_renderer.grid.isWin():
print('You win!')
exit()
if __name__ == '__main__':
main()