-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapCreator.py
46 lines (42 loc) · 1.16 KB
/
MapCreator.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
from PIL import Image
filename = input('Inserire nome file(no estensione): ')
im = Image.open(filename+".png")
file = open(filename+".ts", "w+")
pix = im.load()
x = int(im.width)
y = int(im.height)
i=0
j=0
blackt = (0, 0, 0, 255)
whitet = (255, 255, 255, 255)
spawnt = (255, 0, 0, 255)
loadt = (0, 0, 255, 255)
enemyt = (0, 255, 255, 255)
finalt = (0, 255, 0, 255)
treasuret = (255, 255, 0, 255)
black = (0, 0, 0)
white = (255, 255, 255)
spawn = (255, 0, 0)
load = (0, 0, 255)
enemy = (0, 255, 255)
final = (0, 255, 0)
treasure = (255, 255, 0)
for j in range(y):
for i in range(x):
if pix[i, j] == blackt | black:
file.write('*')
elif pix[i, j] == whitet | white:
file.write('0')
elif pix[i, j] == spawnt | spawn:
file.write('S')
elif pix[i, j] == loadt | load:
file.write('L')
elif pix[i, j] == finalt | final:
file.write('F')
elif pix[i, j] == enemyt | enemy:
file.write('E')
elif pix[i, j] == treasuret | treasure:
file.write('T')
else:
file.write('?')
file.write('\n')