-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmask.py
50 lines (42 loc) · 1.57 KB
/
mask.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
44
45
46
47
48
49
50
import pyxel
import json
import sys
class App:
def __init__(self, room_nb, difficulty, path):
self.room_nb = room_nb
self.frame_delay = 30
self.objects = []
self.types = []
self.rooms = []
self.difficulty = difficulty
self.paths = path
pyxel.init(128 * room_nb, 256, title='SpaceWarp')
pyxel.load("ressources/assets.pyxres")
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.frame_count < 1:
return
for i in range(self.room_nb):
object = [[pyxel.pget(x * 8 + 128 * i, y * 8) for y in range(16)] for x in range(16)]
self.objects.append(object)
types = [[pyxel.pget(x * 8 + 128 * i, y * 8 + 128) for y in range(16)] for x in range(16)]
self.types.append(types)
self.rooms = [self.room_nb, self.objects, self.types]
with open(self.paths[self.difficulty], 'w') as file:
json.dump(self.rooms, file)
pyxel.quit()
def draw(self):
pyxel.cls(0)
pyxel.bltm(0, 0, self.difficulty + 1, 0, 128, 128 * self.room_nb, 256)
path = ['ressources/mask_easy.json', 'ressources/mask_normal.json', 'ressources/mask_hard.json', 'ressources/mask_lunatic.json']
combine = int(sys.argv[3])
full_mask = []
if combine == 0:
App(int(sys.argv[1]), int(sys.argv[2]), path)
else:
for i in path:
with open(i, 'r') as file:
mask = json.load(file)
full_mask.append(mask)
with open('ressources/mask.json', 'w') as file:
json.dump(full_mask, file)