Back to main page
summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorMax <mahn.maxwell@gmail.com>2021-10-18 09:08:39 -0400
committerMax <mahn.maxwell@gmail.com>2021-10-18 09:08:39 -0400
commit35229e33ac43c4dd1dd6537b791d97ba4ecbc557 (patch)
treefe358ae5be91e121da187c58c34c7bc0791987de /main.py
parent59a03755a10aadd729b1610b6cb71d087eea44e0 (diff)
fixed graphics
Diffstat (limited to 'main.py')
-rw-r--r--main.py20
1 files 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()