-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnewgame.py
50 lines (40 loc) · 1.5 KB
/
newgame.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
import pygame
#from Board import GameBoard
# drawing background gameboard
# initialization and start game
# detect mouse clicks, update graphics based on revealed board
class new_game:
def __init__(self, rows, cols, mines):
self.m_rows = rows
self.m_cols = cols
self.m_mines = mines
#self.m_board = GameBoard(self.m_cols, self.m_rows, self.m_mines)
def start_game(self):
#create window, draw cells, create number and mine grid
pygame.init()
logo = pygame.image.load("mine_tile.png")
pygame.display.set_icon(logo)
pygame.display.set_caption("MINESWEEPER")
# n: number of pixels down
# m: number of pixels across
# gives you an nxm window
n = self.m_rows * 20
m = self.m_cols * 20
screen = pygame.display.set_mode((n,m))
# Create background surface, fill with white color
background = pygame.Surface(screen.get_size())
background.fill((255,255,255))
background = background.convert()
screen.blit(background, (0,0))
# Create animate board of pink tiles
image = pygame.image.load("tile.png")
for x in range(self.m_rows):
for y in range(self.m_cols):
screen.blit(image, (x*20,y*20))
pygame.display.flip()
def run_game(self):
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False