Collisions are working

This commit is contained in:
Yohann D'ANELLO
2020-11-06 18:03:30 +01:00
parent 54bb2d1416
commit d06a42469a
2 changed files with 24 additions and 8 deletions

View File

@ -76,6 +76,22 @@ class TestEntities(unittest.TestCase):
Test some random stuff with players.
"""
player = Player()
self.map.add_entity(player)
player.move(1, 6)
self.assertEqual(player.strength, 5)
self.assertEqual(player.health, player.maxhealth)
self.assertEqual(player.maxhealth, 20)
# Test movements and ensure that collisions are working
self.assertFalse(player.move_up())
self.assertTrue(player.move_left())
self.assertFalse(player.move_left())
for i in range(8):
self.assertTrue(player.move_down())
self.assertFalse(player.move_down())
self.assertTrue(player.move_right())
self.assertTrue(player.move_right())
self.assertTrue(player.move_right())
self.assertFalse(player.move_right())
self.assertTrue(player.move_down())
self.assertTrue(player.move_down())