test_tmx.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. class TestVisibilityMatrix(BaseTest):
  7. def test_tmx_to_matrix(self):
  8. tmx_map = TMXMap('tests/fixtures/map_001.tmx')
  9. matrixes = Matrixes()
  10. assert 5 == tmx_map.width
  11. assert 5 == tmx_map.height
  12. matrixes.initialize_empty_matrix(
  13. 'visibility',
  14. matrix_height=5,
  15. matrix_width=5,
  16. value_structure=['height', 'opacity'],
  17. )
  18. assert [
  19. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  20. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  21. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  22. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  23. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  24. ] == matrixes.get_matrix('visibility')
  25. fill_matrix(tmx_map, matrixes, 'terrain', 'visibility', ['height', 'opacity'])
  26. assert [
  27. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  28. [(0.0, 0.0), (2.0, 100.0), (2.0, 100.0), (2.0, 100.0), (0.0, 0.0), ],
  29. [(0.0, 0.0), (2.0, 100.0), (0.0, 0.0), (2.0, 100.0), (0.0, 0.0), ],
  30. [(0.0, 0.0), (2.0, 100.0), (2.0, 100.0), (2.0, 100.0), (0.0, 0.0), ],
  31. [(0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), ],
  32. ] == matrixes.get_matrix('visibility')