Exemple #1
0
class AsteroidPlayerCollisionTrue(unittest.TestCase):
    def setUp(self):
        self.game = Game((100, 100), 0, 1, [('w', 0)], "",
                         [Asteroid(50, 50, 0, 0, 10, 100, 100)])

    def test(self):
        self.game.check_collision()
        self.assertEqual(self.game.player.health, 2)
Exemple #2
0
class AsteroidShotCollisionTrue(unittest.TestCase):
    def setUp(self):
        self.game = Game((100, 100), 0, 1, [('w', 0)], "",
                         [Asteroid(50, 50, 0, 0, 80, 100, 100)])
        self.game.shots.append(Shot(self.game.player, 100, 100))

    def test(self):
        self.game.check_collision()
        self.assertEqual(len(self.game.shots), 0)
        self.assertEqual(len(self.game.asteroids), 3)
Exemple #3
0
class CheckUFOPlayerCollision(unittest.TestCase):
    def setUp(self):
        self.game = Game((100, 100), 0, 1,
                         [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)],
                         "s",
                         [Asteroid(0, 0, 0, 0, 1, 100, 100)])

    def test(self):
        self.game.create_ufo()
        self.game.player.x = self.game.ufo_list[0].x
        self.game.player.y = self.game.ufo_list[0].y
        self.game.check_collision()
        self.assertTrue(self.game.player.health == 2)
Exemple #4
0
class AsteroidPlayerCollision(unittest.TestCase):
    def setUp(self):
        self.game = Game((100, 100), 0, 1, [('w', 0)], "",
                         [Asteroid(0, 0, 0, 0, 10, 100, 100)])

    def test(self):
        self.assertTrue(not self.game.check_collision())
Exemple #5
0
class CheckUFOPCollision(unittest.TestCase):
    def setUp(self):
        self.game = Game((100, 100), 0, 1,
                         [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)],
                         "s",
                         [Asteroid(0, 0, 0, 0, 1, 100, 100)])

    def test(self):
        self.game.create_ufo()
        self.game.shots.append(self.game.ufo_list[0].shot(self.game.player))
        self.game.shots[0].x = self.game.ufo_list[0].x
        self.game.shots[0].y = self.game.ufo_list[0].y
        self.game.check_collision()
        self.assertEqual(len(self.game.ufo_list), 0)
        self.assertEqual(self.game.player.score, 2)
        self.assertEqual(len(self.game.shots), 0)
Exemple #6
0
class CheckBotuseColisionTest(unittest.TestCase):
    def setUp(self):
        self.game = Game((1000, 1000), 0, 1,
                         [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)],
                         "s",
                         [Asteroid(0, 0, 0, 0, 80, 100, 100)])

    def test(self):
        self.game.hp_bonuses.append(
            HPBonus(self.game.player, 100, 100, (0, 0, 0)))
        self.game.shield_bonuses.append(
            ShieldBonus(self.game.player, 100, 100, (0, 0, 0)))
        self.game.rate_fire_bonuses.append(
            RateOfFireBonus(self.game.player, 100, 100, (0, 0, 0)))
        self.game.check_collision()
        self.assertEqual(self.game.player.health, 4)
        self.assertEqual(self.game.player.immortal_time,
                         self.game.default_immortal_time * 2)
        self.assertEqual(self.game.player.refresh_speed, 2)