Added a first try for player movement
This commit is contained in:
parent
2cea53f519
commit
03560f4407
|
@ -0,0 +1,45 @@
|
|||
import curses
|
||||
#import term_manager.py as term
|
||||
import time
|
||||
|
||||
filename = "map.txt"
|
||||
A = open(filename)
|
||||
M = []
|
||||
|
||||
i = 0
|
||||
for lines in A :
|
||||
B = list(lines)[:-1]
|
||||
M.append(B)
|
||||
i+=1
|
||||
print(M)
|
||||
|
||||
def main(stdscr):
|
||||
for y in range(len(M)): #len(M)
|
||||
for x in range(len(M[0])): #len(M[0])
|
||||
stdscr.addstr(y,x,M[y][x])
|
||||
stdscr.refresh()
|
||||
|
||||
cur = [1,6] #(y,x)
|
||||
stdscr.addstr(1,6,'@')
|
||||
stdscr.refresh()
|
||||
|
||||
for i in range(10) :
|
||||
stdscr.addstr(cur[0],cur[1],'.')
|
||||
key = stdscr.getkey()
|
||||
if key == 'z' :
|
||||
if cur[0]>0 and M[cur[0]-1][cur[1]] != '#' :
|
||||
cur[0] = cur[0]-1
|
||||
if key == 's' :
|
||||
if cur[0]<len(M)-1 and M[cur[0]+1][cur[1]] != '#' :
|
||||
cur[0] = cur[0]+1
|
||||
if key == 'q' :
|
||||
if cur[1]>0 and M[cur[0]][cur[1]-1] != '#' :
|
||||
cur[1] = cur[1]-1
|
||||
if key == 'd' :
|
||||
if cur[1]<len(M[0]) and M[cur[0]][cur[1]+1] != '#' :
|
||||
cur[1] = cur[1]+1
|
||||
stdscr.addstr(cur[0],cur[1],'@')
|
||||
#stdscr.refresh()
|
||||
|
||||
|
||||
curses.wrapper(main)
|
Loading…
Reference in New Issue