Wed Apr 17 01:05:42 PDT 2002
[netwalk.git] / tile.e
blobb17cf3b282ad2391005dd8a29b77271c6894ceac
1 class TILE
2 inherit DIR_CONSTANT
3 creation make, make_server_bottom, make_server_top
4 feature
5 tile_server_top : INTEGER is 1
6 tile_server_bottom : INTEGER is 2
7 tile_normal : INTEGER is 3
8 tile_terminal : INTEGER is 4
10 type : INTEGER
12 neighbour : ARRAY[BOOLEAN]
14 x, y : INTEGER
16 put_xy(new_x, new_y : INTEGER) is
18 x := new_x
19 y := new_y
20 end
22 is_connected : BOOLEAN
24 connect is
26 is_connected := True
27 end
29 disconnect is
31 is_connected := False
32 end
34 neighbour_count : INTEGER
36 count_neighbours is
37 local
38 dir : INTEGER
40 from dir := 1
41 until dir > 4
42 loop
43 if neighbour.item(dir) then
44 neighbour_count := neighbour_count + 1
45 end
46 dir := dir + 1
47 end
49 if neighbour_count = 1 and then
50 type = tile_normal then
51 type := tile_terminal
52 end
53 end
55 make is
57 type := tile_normal
58 !!neighbour.make(1, 4)
59 end
61 make_server_bottom is
63 type := tile_server_bottom
64 !!neighbour.make(1, 4)
65 end
67 make_server_top is
69 type := tile_server_top
70 !!neighbour.make(1, 4)
71 end
72 end