コード例 #1
0
 def test_compute_new_coordinate(self):
     hero = Hero(0, 0, 90)
     bullet = Bullet(hero)
     step = 0
     while step < 3:
         bullet.compute_new_coordinate(self.game_object.game_field)
         step += STEP_INTERVAL
     self.assertEqual(bullet.x1, 0, 'Bullet coordinate x is incorrect!')
     self.assertEqual(bullet.y1, 15, 'Bullet coordinate y is incorrect!')
コード例 #2
0
 def test_compute_new_coordinate(self):
     hero = Hero(0, 0, 90)
     bullet = Bullet(hero)
     step = 0
     while step < 3:
         bullet.compute_new_coordinate(self.game_object.game_field)
         step += STEP_INTERVAL
     self.assertEqual(bullet.x1, 0, 'Bullet coordinate x is incorrect!')
     self.assertEqual(bullet.y1, 15, 'Bullet coordinate y is incorrect!')
コード例 #3
0
 def test_check_collision_without_kill(self):
     hero = Hero(0, 0, 90)
     invader = Invader(7, 31, 90, 10, 0)
     bullet = Bullet(hero)
     self.units = [hero, invader, bullet]
     step = 0
     while step < 3:
         bullet.compute_new_coordinate(self.game_object.game_field)
         step += STEP_INTERVAL
     bullet.check_collision(invader, self.units)
     self.assertEqual(bullet.is_dead, False, 'Bullet is dead!')
     self.assertEqual(invader.is_dead, False, 'Invader is dead!')
     self.assertEqual(hero.bonus, 0, 'Incorrect bonus for hero!')
     self.assertEqual(len(self.units), 3, 'Incorrect count of units after check collision!!')
コード例 #4
0
 def test_check_collision_without_kill(self):
     hero = Hero(0, 0, 90)
     invader = Invader(7, 31, 90, 10, 0)
     bullet = Bullet(hero)
     self.units = [hero, invader, bullet]
     step = 0
     while step < 3:
         bullet.compute_new_coordinate(self.game_object.game_field)
         step += STEP_INTERVAL
     bullet.check_collision(invader, self.units)
     self.assertEqual(bullet.is_dead, False, 'Bullet is dead!')
     self.assertEqual(invader.is_dead, False, 'Invader is dead!')
     self.assertEqual(hero.bonus, 0, 'Incorrect bonus for hero!')
     self.assertEqual(len(self.units), 3,
                      'Incorrect count of units after check collision!!')