forked from Chasmiccoder/acm-rpg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallGenerator.py
58 lines (40 loc) · 1.21 KB
/
wallGenerator.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
51
52
53
54
55
56
57
58
# Script that uses the map outline to find the exact coordinates of the walls
from PIL import Image
from numpy import asarray
import numpy as np
import cv2
def removeFlagged(coordinate_list):
# For insta, twitter blocks
flagged = [[31,40],[32,40],[33,41],[34,41],[35,40],[36,40],[37,39],[38,39],[26,42],[25,42],[45,32],[46,32],[10,38],[9,38],[8,38]]
newList = []
for point in coordinate_list:
if point not in flagged:
newList.append(point)
return newList
image = cv2.imread('./images/map_outline.png')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = np.array(image)
coordinate_list = []
x_offset = 9
y_offset = 2
y = 0
i = 0
while i < len(image):
j = 0
x = 0
while j < len(image[i]):
pixel = image[i][j]
if list(pixel) == [196, 196, 196]:
coordinate_list.append([x-x_offset,y-y_offset])
j += 32
x += 1
i += 32
y += 1
coordinate_list = removeFlagged(coordinate_list)
print(coordinate_list[0])
file_list = []
for i in coordinate_list:
s = "[utils.asGridCoord({x},{y})]: true,\n".format(x=i[0], y=i[1])
file_list.append(s)
with open("wall_coordinates.txt", "w") as file:
file.writelines(file_list)