def pause(self, pauser): if self.gameState < self.STOPPED: wasPaused = self.isPaused self.__pauseTracker[pauser] = None #value is arbitrary if not wasPaused: #just paused self.__playPauseLerp() CToolbar.getClock().pause()
def resume(self, resumer): if self.gameState < self.STOPPED: if resumer in self.__pauseTracker: del self.__pauseTracker[resumer] if not self.isPaused: #just resumed self.__playPauseLerp() CToolbar.getClock().resume()
def instantiateField(self, dims, nMines): self.__minesToLay = nMines #lay mines after first click field = GuiField(self, dims, 0, self.__setFinalizeConstruct, ()) #NodePath.__init__(self, "Funky Chicken") CToolbar.getMineCounter().setNumMines(nMines) return field
def onMouseClickCancelled(self, source, coords, button): if button == MouseDispatcher.LEFT_BUTTON: if source: source.unhighlight() #revert elif button == MouseDispatcher.RIGHT_BUTTON | \ MouseDispatcher.LEFT_BUTTON: self.disengageSweeper() if self.game.gameState < GuiGame.STOPPED: #make sure the game didn't end on last click CToolbar.getSmiley().setSmileTex()
def start(self, startCell): if self.gameState == self.IDLE: self.field.layMines(self.__minesToLay, (startCell,)) self.__minesToLay = 0 self.__winTgt = reduce(operator.mul, self.field.dims) - \ self.field.nMines if not self.isPaused: CToolbar.getClock().start() else: CToolbar.getClock().reset() self.__gameState = self.PLAYING
def onMouseClickPrep(self, source, coords, button): messenger.send("hideChildren") if button == MouseDispatcher.LEFT_BUTTON: if source and (source.state == GuiCell.UNEXPLORED or source.state == GuiCell.QUESTIONMARK): source.highlight() CToolbar.getSmiley().setOTex() elif button == MouseDispatcher.RIGHT_BUTTON | \ MouseDispatcher.LEFT_BUTTON: self.engageSweeper() CToolbar.getSmiley().setOTex()
def dispose(self): self.cTool = None CToolbar.getClock().stop() if self.__cameraControl: self.disposeCameraControl() self.removeNode()
def stop(self): if self.gameState < self.STOPPED: CToolbar.getClock().pause() self.__gameState = self.STOPPED
def setFlags(self, value): self.__flags = value CToolbar.getMineCounter().setTextures(self.nMines - value)