-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfov_demoutil.py
29 lines (26 loc) · 921 Bytes
/
fov_demoutil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from mathutil import *
def load_from_file( filename ):
# Expect a text file containing a map, w/ legend: '#' wall, '.' floor, 'X' viewer path (optional)
lines = open(filename, 'rt').read().split('\n')
path = []
visibilityMap = None
if lines:
w = len(lines[0])
h = len(lines)
visibilityMap = Map2D(w,h)
for y in range(h):
for x in range(w):
char = lines[y][x]
p = ivec2(x,y)
if char == '#':
visibilityMap.set(p,0)
elif char == '.':
visibilityMap.set(p,1)
elif char == '@':
visibilityMap.set(p,1)
path.append(p)
return (visibilityMap, path)
if __name__ == '__main__':
vmap, path = load_from_file("fov_demomap_1.txt")
print(vmap)
print(path)