From 35229e33ac43c4dd1dd6537b791d97ba4ecbc557 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 18 Oct 2021 09:08:39 -0400 Subject: fixed graphics --- main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 75e4204..9b3f06a 100644 --- a/main.py +++ b/main.py @@ -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() -- cgit v1.2.3