squirrel-battle/dungeonbattle/proof_of_concept.py

37 lines
1.3 KiB
Python

#!/usr/bin/env python
from .interfaces import Map
from .term_manager import TermManager
def proof_of_concept() -> None:
m = Map.load("example_map.txt")
with TermManager() as term_manager:
stdscr = term_manager.screen
stdscr.addstr(0, 0, m.draw_string())
stdscr.refresh()
cur = [1, 6] # (y,x)
stdscr.addstr(1, 6, '🐿️')
stdscr.refresh()
while True:
key = stdscr.getkey()
stdscr.addstr(cur[0], cur[1], '.')
if key == 'z' or key == 'KEY_UP':
if cur[0] > 0 and m.tiles[cur[0] - 1][cur[1]].value != '#':
cur[0] = cur[0] - 1
if key == 's' or key == 'KEY_DOWN':
if cur[0] < m.height - 1 and \
m.tiles[cur[0] + 1][cur[1]].value != '#':
cur[0] = cur[0] + 1
if key == 'q' or key == 'KEY_LEFT':
if cur[1] > 0 and m.tiles[cur[0]][cur[1] - 1].value != '#':
cur[1] = cur[1] - 1
if key == 'd' or key == 'KEY_RIGHT':
if cur[1] < m.width and \
m.tiles[cur[0]][cur[1] + 1].value != '#':
cur[1] = cur[1] + 1
stdscr.addstr(cur[0], cur[1], '🐿️')