Also use arrow keys in example

This commit is contained in:
Yohann D'ANELLO 2020-10-16 15:32:15 +02:00
parent ef6e5d66ca
commit c8de541eee

View File

@ -23,17 +23,17 @@ def proof_of_concept() -> None:
while True:
key = stdscr.getkey()
stdscr.addstr(cur[0], cur[1], '.')
if key == 'z':
if key == 'z' or key == 'KEY_UP':
if cur[0] > 0 and matrix[cur[0] - 1][cur[1]] != '#':
cur[0] = cur[0] - 1
if key == 's':
if key == 's' or key == 'KEY_DOWN':
if cur[0] < len(matrix) - 1 and \
matrix[cur[0] + 1][cur[1]] != '#':
cur[0] = cur[0] + 1
if key == 'q':
if key == 'q' or key == 'KEY_LEFT':
if cur[1] > 0 and matrix[cur[0]][cur[1] - 1] != '#':
cur[1] = cur[1] - 1
if key == 'd':
if key == 'd' or key == 'KEY_RIGHT':
if cur[1] < len(matrix[0]) and \
matrix[cur[0]][cur[1] + 1] != '#':
cur[1] = cur[1] + 1