-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetWorld.py
43 lines (34 loc) · 1.39 KB
/
GetWorld.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class GetWorld:
def __init__(self):
self.world = []
self.worldRF = open("Objects").readlines()
self.worldF = open("Objects")
def readWorld(self):
for line in self.worldRF:
if line[0] == '@':
self.world.append([])
elif line[0] == '#':
self.world[-1].append([])
elif line[0] != '@' and line[0] != 'c':
a = [int(coord) for coord in line.split(" ")]
self.world[-1][-1].append((a[0], a[1], a[2]))
elif line[0] == 'c':
a = [int(coord) for coord in line[2:].split(" ")]
self.world[-1][-1].append((a[0], a[1], a[2]))
return self.world
def generateWorld(self, obj):
worldRF = open("Labirynth").readlines()
world = []
for line, y in zip(worldRF, range(len(worldRF))):
for cube, x in zip(line, range(len(line))):
if cube == '#':
world.append([])
for sideAll in obj:
side = sideAll[:-1]
world[-1].append([])
for point in side:
(xC, yC, zC) = point
cubeTmp = (xC+2*x, yC+2*y, zC)
world[-1][-1].append(cubeTmp)
world[-1][-1].append(sideAll[-1])
return world