diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1,4 +1,5 @@ import curses +import math key_left = ['h', 'a'] key_right = ['l', 'd'] @@ -11,12 +12,19 @@ maxY = 4 gamestate = [[0 for mx in range(maxX)] for my in range(maxY)] -gamestate[2][2] = 1 -gamestate[1][2] = 1 -gamestate[3][2] = 1 +gamestate[0][0] = 128 +gamestate[2][2] = 2048 +gamestate[1][2] = 64 +gamestate[3][2] = 2 def DrawSquare(x, y, val): - stdscr.addstr(y, x, "+") + val_len = len(str(val)) + if val_len > 4: + val_len = 4 + stdscr.addstr(y, x, "+====+") + stdscr.addstr(y + 1, x, "|" + " " * math.ceil((4-val_len)/2) + str(val) + " " * math.floor((4-val_len)/2) + "|") + stdscr.addstr(y + 2, x, "+====+") + def FullDraw(): for i in range(maxY): @@ -41,11 +49,11 @@ def MoveUp(): # Init stdscr = curses.initscr() -stdscr.noecho() +curses.noecho() while True: FullDraw() userin = stdscr.getch() - if userin == 'q': + if userin == 81: break if userin in key_left: MoveLeft() |
