Use a ResourceManager to find assets

This commit is contained in:
Yohann D'ANELLO
2020-11-19 02:49:59 +01:00
parent d92a5e1629
commit 00f843754a
5 changed files with 21 additions and 4 deletions

View File

@ -4,6 +4,7 @@ from squirrelbattle.entities.items import Bomb, Heart, Item
from squirrelbattle.entities.monsters import Beaver, Hedgehog, Rabbit, TeddyBear
from squirrelbattle.entities.player import Player
from squirrelbattle.interfaces import Entity, Map
from squirrelbattle.resources import ResourceManager
class TestEntities(unittest.TestCase):
@ -11,7 +12,7 @@ class TestEntities(unittest.TestCase):
"""
Load example map that can be used in tests.
"""
self.map = Map.load("squirrelbattle/assets/example_map.txt")
self.map = Map.load(ResourceManager.get_asset_path("example_map.txt"))
self.player = Player()
self.map.add_entity(self.player)
self.player.move(self.map.start_y, self.map.start_x)

View File

@ -2,6 +2,7 @@ import unittest
from squirrelbattle.display.texturepack import TexturePack
from squirrelbattle.interfaces import Map, Tile
from squirrelbattle.resources import ResourceManager
class TestInterfaces(unittest.TestCase):
@ -18,7 +19,7 @@ class TestInterfaces(unittest.TestCase):
"""
Try to load a map from a file.
"""
m = Map.load("squirrelbattle/assets/example_map.txt")
m = Map.load(ResourceManager.get_asset_path("example_map.txt"))
self.assertEqual(m.width, 52)
self.assertEqual(m.height, 17)