Back to main page
summaryrefslogtreecommitdiff
path: root/main.py
blob: 9b3f06aa83eaa66bb94694f65595bd12fff72674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import curses
import math

key_left = ['h', 'a']
key_right = ['l', 'd']
key_down = ['j', 's']
key_up = ['k', 'w']


maxX = 4
maxY = 4

gamestate = [[0 for mx in range(maxX)] for my in range(maxY)]

gamestate[0][0] = 128
gamestate[2][2] = 2048
gamestate[1][2] = 64
gamestate[3][2] = 2

def DrawSquare(x, y, val):
    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):
        for j in range(maxX):
            if gamestate[i][j] == 0:
                continue
            DrawSquare(j * 5, i * 3, gamestate[i][j])

def MoveLeft():
    pass

def MoveRight():
    pass

def MoveDown():
    pass

def MoveUp():
    pass



# Init
stdscr = curses.initscr()
curses.noecho()
while True:
    FullDraw()
    userin = stdscr.getch()
    if userin == 81:
        break
    if userin in key_left:
        MoveLeft()
    elif userin in key_right:
        MoveRight()
    elif userin in key_down:
        MoveDown()
    elif userin in key_up:
        MoveUp()




curses.endwin()