def restart(self, event): size = 4 self.gameboard = game2048.board(size) boardMatrix = self.gameboard.getBoard() self.view.render(boardMatrix, 0) self.window.bind('<Up>', self.moveupEvent) self.window.bind('<Down>', self.movedownEvent) self.window.bind('<Left>', self.moveleftEvent) self.window.bind('<Right>', self.moverightEvent)
def __init__(self, size): self.window = tkinter.Tk() self.view = view.View(self.window, size) self.window.bind('<Up>', self.moveup) self.window.bind('<Down>', self.movedown) self.window.bind('<Left>', self.moveleft) self.window.bind('<Right>', self.moveright) self.window.bind('<r>', self.restart) self.gameboard = game2048.board(size) boardMatrix = self.gameboard.getBoard() self.view.render(boardMatrix, 0) tkinter.mainloop()
def __init__(self, size): self.window = tkinter.Tk() self.window.title("2048 ParallelGame") self.view = view.View(self.window, size) self.window.bind('<Up>', self.moveupEvent) self.window.bind('<Down>', self.movedownEvent) self.window.bind('<Left>', self.moveleftEvent) self.window.bind('<Right>', self.moverightEvent) self.window.bind('<r>', self.restart) self.window.bind('<c>', self.calNextMoveEvent) self.window.bind('<p>', self.robotMode) self.gameboard = game2048.board(size) boardMatrix = self.gameboard.getBoard() self.view.render(boardMatrix, 0) self.rbt = robot.Robot() while 1: self.window.update_idletasks() self.window.update()
def restart(self, event): size = 4 self.gameboard = game2048.board(size) boardMatrix = self.gameboard.getBoard() self.view.render(boardMatrix, 0)