Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameBoard(QtGui.QWidget):
- def __init__(self, boardWidth, boardHeight, bombCount):
- self.width = boardWidth
- self.height = boardHeight
- self.bombCount = bombCount
- self.tiles = []
- def setup(self, layout):
- print("::", self.height, " :: ", self.width)
- for currRow in range(self.height):
- self.tiles.append([])
- for currCol in range(self.width):
- self.tiles[currRow].append(MineButton())
- self.tiles[currRow][currCol].setFixedSize(20, 20)
- self.tiles[currRow][currCol].row = currRow
- self.tiles[currRow][currCol].column = currCol
- self.tiles[currRow][currCol].parent = self
- self.tiles[currRow][currCol].revealed = False
- layout.addWidget(self.tiles[currRow][currCol], currRow, currCol)
- #print("connect: ", currRow, " :: ", currCol)
- QtCore.QObject.connect(self.tiles[currRow][currCol], QtCore.SIGNAL("clicked()"), self.revealButton)
- def startNewGame(self):
- print("startNewGame")
- self.setBombs()
- for tileRow in self.tiles:
- for tile in tileRow:
- tile.reset()
- def revealButton(self):
- print("kuku")
- button = self.sender()
- print(button)
- button.reveal()
- if button.hasBomb:
- self.gameOver()
Add Comment
Please, Sign In to add comment