-
Notifications
You must be signed in to change notification settings - Fork 0
/
unicurses16.py
46 lines (31 loc) · 909 Bytes
/
unicurses16.py
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
import curses
from player16 import *
def main():
## Curses normal init sequence
stdscr = curses.initscr()
if not curses.has_colors():
print("Your terminal emulator needs to have colors.")
return 0
curses.noecho() # no echo, but we still see the cursor
curses.curs_set(False) #turns off the cursor drawing
stdscr.keypad(True) # allows special keys and arrow keys
try:
curses.start_color()
avatar = Player(stdscr, "@", curses.COLOR_RED, curses.COLOR_BLACK, curses.A_BOLD)
stdscr.attron(curses.color_pair(1))
stdscr.vline("|", 10)
stdscr.hline("-", 10)
stdscr.attroff(curses.color_pair(1))
while True:
key = stdscr.getch()
avatar.move(key)
if key == 27:
break
except Exception as e:
stdscr.addstr(0,0,str(e))
stdscr.getch()
finally:
curses.endwin()
return 0
if __name__ == '__main__':
main()