def setUp(self): controller = Controller() self.unit1 = Hero(0, 0, 45, 0, 0, 1, 0.5, 'hero', 'bullet_hero', 10, controller) self.unit2 = Invader(10, 10, 45, 0, 10, 'invader1', 'bullet_invader', 10, controller) controller.collisions[self.unit1.id] = [] controller.collisions[self.unit2.id] = []
def test_compute_new_coordinate(self): unit = Invader(500, 500, 0, 10, 100, 'invader1', 'bullet_invader', 10, Controller()) while unit.angle < 360: unit.compute_new_coordinate(1) distance = math.sqrt(((unit.x1 - unit.x)**2) + ((unit.y1 - unit.y)**2)) self.assertTrue(0.01 <= distance / unit.speed <= 1.01) unit.angle += 20