Remove proof of concept, <3 eichornchen
This commit is contained in:
parent
8437482139
commit
c85166ff89
|
@ -1,45 +0,0 @@
|
|||
from .interfaces import Map, Tile
|
||||
from .term_manager import TermManager
|
||||
|
||||
|
||||
def proof_of_concept() -> None:
|
||||
"""
|
||||
Read an example map, parse it, then the (squirrel) player can move freely.
|
||||
"""
|
||||
# Load the example map
|
||||
m = Map.load("example_map.txt")
|
||||
|
||||
# Create the context manager to manipulate the screen
|
||||
with TermManager() as term_manager:
|
||||
stdscr = term_manager.screen
|
||||
|
||||
# Draw the full map
|
||||
stdscr.addstr(0, 0, m.draw_string())
|
||||
stdscr.refresh()
|
||||
|
||||
cur = [1, 6] # (y,x)
|
||||
# We are a squirrel
|
||||
stdscr.addstr(1, 6, '🐿')
|
||||
stdscr.refresh()
|
||||
|
||||
while True:
|
||||
# Get movements of the user
|
||||
key = stdscr.getkey()
|
||||
stdscr.addstr(cur[0], cur[1], Tile.FLOOR.value)
|
||||
next_pos = cur[:]
|
||||
if key == 'z' or key == 'KEY_UP':
|
||||
next_pos[0] = cur[0] - 1
|
||||
if key == 's' or key == 'KEY_DOWN':
|
||||
next_pos[0] = cur[0] + 1
|
||||
if key == 'q' or key == 'KEY_LEFT':
|
||||
next_pos[1] = cur[1] - 1
|
||||
if key == 'd' or key == 'KEY_RIGHT':
|
||||
next_pos[1] = cur[1] + 1
|
||||
# Check if we stay in the bounds
|
||||
if 0 <= next_pos[0] < m.height and 0 <= next_pos[0] < m.width:
|
||||
next_tile = m.tiles[next_pos[0]][next_pos[1]]
|
||||
# Check if the new position is valid
|
||||
if next_tile.can_walk():
|
||||
cur = next_pos
|
||||
# Draw the squirrel
|
||||
stdscr.addstr(cur[0], cur[1], '🐿')
|
Loading…
Reference in New Issue