|
@@ -0,0 +1,37 @@
|
|
1
|
+# coding: utf-8
|
|
2
|
+from synergine2_xyz.map import TMXMap
|
|
3
|
+from synergine2_xyz.physics import Matrixes
|
|
4
|
+from synergine2_xyz.tmx_utils import fill_matrix
|
|
5
|
+from tests import BaseTest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+class TestVisibilityMatrix(BaseTest):
|
|
9
|
+ def test_tmx_to_matrix(self):
|
|
10
|
+ tmx_map = TMXMap('tests/fixtures/map_001.tmx')
|
|
11
|
+ matrixes = Matrixes()
|
|
12
|
+
|
|
13
|
+ assert 5 == tmx_map.width
|
|
14
|
+ assert 5 == tmx_map.height
|
|
15
|
+
|
|
16
|
+ matrixes.initialize_empty_matrix(
|
|
17
|
+ 'visibility',
|
|
18
|
+ matrix_height=5,
|
|
19
|
+ matrix_width=5,
|
|
20
|
+ value_structure=['height', 'opacity'],
|
|
21
|
+ )
|
|
22
|
+ assert [
|
|
23
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
24
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
25
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
26
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
27
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
28
|
+ ] == matrixes.get_matrix('visibility')
|
|
29
|
+
|
|
30
|
+ fill_matrix(tmx_map, matrixes, 'terrain', 'visibility', ['height', 'opacity'])
|
|
31
|
+ assert [
|
|
32
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
33
|
+ [(0.0, 0.0), (2.0, 100.0), (2.0, 100.0), (2.0, 100.0), (0.0, 0.0), ],
|
|
34
|
+ [(0.0, 0.0), (2.0, 100.0), (0.0, 0.0), (2.0, 100.0), (0.0, 0.0), ],
|
|
35
|
+ [(0.0, 0.0), (2.0, 100.0), (2.0, 100.0), (2.0, 100.0), (0.0, 0.0), ],
|
|
36
|
+ [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
|
|
37
|
+ ] == matrixes.get_matrix('visibility')
|