-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelLoader.py
More file actions
24 lines (23 loc) · 976 Bytes
/
levelLoader.py
File metadata and controls
24 lines (23 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Level:
def __init__(self, txtFile = 'levels/default.txt'):
"""Loads level from txt file.
see how to format in _levelInstructions.txt
to add a level, add relative path.
"""
try:
with open(txtFile) as file:
lines = file.read().splitlines()
self.height = int(lines[0])
del lines[0]
self.width = int(lines[0])
del lines[0]
self.level = lines
except:
print ('********** error, file ' + txtFile + ' file NOT FOUND, continuing with default file...')
with open('levels/default.txt') as file:
lines = file.read().splitlines()
self.height = int(lines[0])
del lines[0]
self.width = int(lines[0])
del lines[0]
self.level = lines