Guest User

Untitled

a guest
May 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. class GameBoard(QtGui.QWidget):
  2.     def __init__(self, boardWidth, boardHeight, bombCount):
  3.         self.width = boardWidth
  4.         self.height = boardHeight
  5.         self.bombCount = bombCount
  6.         self.tiles = []
  7.        
  8.     def setup(self, layout):
  9.         print("::", self.height, " :: ", self.width)
  10.         for currRow in range(self.height):
  11.             self.tiles.append([])
  12.             for currCol in range(self.width):
  13.                 self.tiles[currRow].append(MineButton())
  14.                 self.tiles[currRow][currCol].setFixedSize(20, 20)
  15.                 self.tiles[currRow][currCol].row = currRow
  16.                 self.tiles[currRow][currCol].column = currCol
  17.                 self.tiles[currRow][currCol].parent = self
  18.                 self.tiles[currRow][currCol].revealed = False
  19.                 layout.addWidget(self.tiles[currRow][currCol], currRow, currCol)
  20.                 #print("connect: ", currRow, " :: ", currCol)
  21.                 QtCore.QObject.connect(self.tiles[currRow][currCol], QtCore.SIGNAL("clicked()"), self.revealButton)
  22.                
  23.     def startNewGame(self):
  24.         print("startNewGame")
  25.         self.setBombs()
  26.         for tileRow in self.tiles:
  27.             for tile in tileRow:
  28.                 tile.reset()
  29.                
  30.     def revealButton(self):
  31.         print("kuku")
  32.         button = self.sender()
  33.         print(button)
  34.         button.reveal()
  35.         if button.hasBomb:
  36.             self.gameOver()
Add Comment
Please, Sign In to add comment