2020-10-16 13:23:58 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from .term_manager import TermManager
|
|
|
|
|
|
|
|
|
|
|
|
def proof_of_concept() -> None:
|
|
|
|
matrix = []
|
|
|
|
with open("example_map.txt") as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
matrix.append(line[:-1])
|
|
|
|
|
|
|
|
with TermManager() as term_manager:
|
|
|
|
stdscr = term_manager.screen
|
|
|
|
|
|
|
|
for y in range(len(matrix)):
|
|
|
|
for x in range(len(matrix[0])):
|
|
|
|
stdscr.addstr(y, x, matrix[y][x])
|
|
|
|
stdscr.refresh()
|
|
|
|
|
|
|
|
cur = [1, 6] # (y,x)
|
|
|
|
stdscr.addstr(1, 6, '@')
|
|
|
|
stdscr.refresh()
|
|
|
|
|
|
|
|
while True:
|
|
|
|
key = stdscr.getkey()
|
|
|
|
stdscr.addstr(cur[0], cur[1], '.')
|
2020-10-16 13:32:15 +00:00
|
|
|
if key == 'z' or key == 'KEY_UP':
|
2020-10-16 13:23:58 +00:00
|
|
|
if cur[0] > 0 and matrix[cur[0] - 1][cur[1]] != '#':
|
|
|
|
cur[0] = cur[0] - 1
|
2020-10-16 13:32:15 +00:00
|
|
|
if key == 's' or key == 'KEY_DOWN':
|
2020-10-16 13:23:58 +00:00
|
|
|
if cur[0] < len(matrix) - 1 and \
|
|
|
|
matrix[cur[0] + 1][cur[1]] != '#':
|
|
|
|
cur[0] = cur[0] + 1
|
2020-10-16 13:32:15 +00:00
|
|
|
if key == 'q' or key == 'KEY_LEFT':
|
2020-10-16 13:23:58 +00:00
|
|
|
if cur[1] > 0 and matrix[cur[0]][cur[1] - 1] != '#':
|
|
|
|
cur[1] = cur[1] - 1
|
2020-10-16 13:32:15 +00:00
|
|
|
if key == 'd' or key == 'KEY_RIGHT':
|
2020-10-16 13:23:58 +00:00
|
|
|
if cur[1] < len(matrix[0]) and \
|
|
|
|
matrix[cur[0]][cur[1] + 1] != '#':
|
|
|
|
cur[1] = cur[1] + 1
|
|
|
|
stdscr.addstr(cur[0], cur[1], '@')
|