-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile.py
61 lines (44 loc) · 1.5 KB
/
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
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
59
60
61
import Event
def check_up(tile, tile_map, x, y):
tile.neighbours['up'] = tile_map[y-1][x]
def check_down(tile, tile_map, x, y):
tile.neighbours['down'] = tile_map[y+1][x]
def check_right(tile, tile_map, x, y):
tile.neighbours['right'] = tile_map[y][x+1]
def check_left(tile, tile_map, x, y):
tile.neighbours['left'] = tile_map[y][x-1]
def find_neighbours(tile_map):
max_x, max_y = len(tile_map[0]) - 1, len(tile_map) - 1
for y, row in enumerate(tile_map):
for x, tile in enumerate(row):
if y != 0:
check_up(tile, tile_map, x, y)
if y != max_y:
check_down(tile, tile_map, x, y)
if x != 0:
check_left(tile, tile_map, x, y)
if x != max_x:
check_right(tile, tile_map, x, y)
def find_tile(tile_map, tile_type):
for row in tile_map:
for tile in row:
if tile.type == tile_type:
return tile
class Tile:
def __init__(self):
self.pos = None
self.neighbours = {}
self.image = None
self.is_safe = True
self.is_permitted = True
self.type = ""
self.can_give_interaction = True
# ustawic na wodzie i lotnisku brak interakcji
def is_neighbour(self, possible_neighbour):
if possible_neighbour in self.neighbours.values():
return True
return False
def get_interaction(self):
return Event.Event(self)
def on_drone_enter(self):
pass