コード例 #1
0
    def puntaje(self):

        while (logic.estado_juego(self.matrix) == 'not over'):
            temp = logic.actualizar(self.matrix)
            logic.fileW(temp)
            self.score.set(temp)
        if (logic.estado_juego(self.matrix) == 'lose'):
            logic.fileW(temp)
            time.sleep(2)
            self.master.destroy()
コード例 #2
0
 def key_down(self, event):
     key = repr(event.char)
     if key == c.KEY_BACK and len(self.history_matrixs) > 1:
         self.matrix = self.history_matrixs.pop()
         self.update_grid_cells()
         print('back on step total step:', len(self.history_matrixs))
     elif key in self.commands:
         self.matrix, done = self.commands[repr(event.char)](self.matrix)
         if done:
             self.matrix = logic.add_two(self.matrix)
             # record last move
             self.history_matrixs.append(self.matrix)
             self.update_grid_cells()
             done = False
             if logic.estado_juego(self.matrix) == 'win':
                 self.grid_cells[1][1].configure(
                     text="You", bg=c.BACKGROUND_COLOR_CELL_EMPTY)
                 self.grid_cells[1][2].configure(
                     text="Win!", bg=c.BACKGROUND_COLOR_CELL_EMPTY)
             if logic.estado_juego(self.matrix) == 'lose':
                 self.grid_cells[1][1].configure(
                     text="You", bg=c.BACKGROUND_COLOR_CELL_EMPTY)
                 self.grid_cells[1][2].configure(
                     text="Lose!", bg=c.BACKGROUND_COLOR_CELL_EMPTY)