Also use arrow keys in example

This commit is contained in:
Yohann D'ANELLO 2020-10-16 15:32:15 +02:00 committed by Nicolas Margulies
parent 12413746fd
commit d2f8a3b623
1 changed files with 4 additions and 4 deletions

View File

@ -23,17 +23,17 @@ def proof_of_concept() -> None:
while True: while True:
key = stdscr.getkey() key = stdscr.getkey()
stdscr.addstr(cur[0], cur[1], '.') 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]] != '#': if cur[0] > 0 and matrix[cur[0] - 1][cur[1]] != '#':
cur[0] = cur[0] - 1 cur[0] = cur[0] - 1
if key == 's': if key == 's' or key == 'KEY_DOWN':
if cur[0] < len(matrix) - 1 and \ if cur[0] < len(matrix) - 1 and \
matrix[cur[0] + 1][cur[1]] != '#': matrix[cur[0] + 1][cur[1]] != '#':
cur[0] = cur[0] + 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] != '#': if cur[1] > 0 and matrix[cur[0]][cur[1] - 1] != '#':
cur[1] = 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 \ if cur[1] < len(matrix[0]) and \
matrix[cur[0]][cur[1] + 1] != '#': matrix[cur[0]][cur[1] + 1] != '#':
cur[1] = cur[1] + 1 cur[1] = cur[1] + 1