-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtile.py
32 lines (28 loc) · 927 Bytes
/
tile.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
# --------------------------------------------------------------------------------- #
class Tile:
def __init__(self, img):
self.img = img
self.index = -1
self.edges = []
self.up = []
self.right = []
self.down = []
self.left = []
# draw a single tile
def draw(self, win, x, y):
win.blit(self.img, (x, y))
# set the rules for each tile
def set_rules(self, tiles):
for tile in tiles:
# up
if self.edges[0] == tile.edges[2]:
self.up.append(tile)
# right
if self.edges[1] == tile.edges[3]:
self.right.append(tile)
# down
if self.edges[2] == tile.edges[0]:
self.down.append(tile)
# left
if self.edges[3] == tile.edges[1]:
self.left.append(tile)