render = Render() render.draw_gui_board(game.board.board) while True: direction = input("---") if direction == "a": direction = "left" elif direction == "s": direction = "down" elif direction == "d": direction = "right" elif direction == "w": direction = "up" possible_directions = game.possible_directions(game.board.board) if direction in possible_directions: game.perform_movement(direction) render.draw_gui_board(game.board.board) # Break if game over elif len(possible_directions) == 0: break render.root.mainloop() # https://stackoverflow.com/questions/29158220/tkinter-understanding-mainloop # https://stackoverflow.com/questions/8829751/python-tkinter-how-to-update-information-in-grid
from lib.game import Game import time game = Game() # board = [[2, 4, 8, 16], [32, 64, 128, 256], [512, 1024, 2048, 4096], [8192, 16384, 32768, 65536]] COLORS = COLORSET_1 # Default TILE_SIZE for a 4x4 board is 10 TILE_SIZE = 10 # gui_board = generate_gui_board(game.board.board, COLORS, TILE_SIZE) while True: direction = input("---") if direction == "a": direction = "left" elif direction == "s": direction = "down" if direction in game.possible_directions(game.board.board): print("hello0") game.perform_movement(direction) print("hello1") draw(game.board.board, gui_board, COLORS, TILE_SIZE) print("hello2") ROOT.mainloop() # https://stackoverflow.com/questions/29158220/tkinter-understanding-mainloop # https://stackoverflow.com/questions/8829751/python-tkinter-how-to-update-information-in-grid