def test_find_distance_to_sprite_behind(self):
        test_player = Player(pygame.sprite.LayeredUpdates())
        test_player.rect.y -= 500
        test_net_group = pygame.sprite.Group()
        test_car = Player(pygame.sprite.LayeredUpdates())

        expected = Window.HEIGHT - test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        # Move the test car behind the player
        test_car.rect.x = test_player.rect.x
        test_car.rect.y = test_player.rect.y + 50
        test_net_group.add(test_car)

        expected = test_car.rect.y - test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x -= 10
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x += 20
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x += 1000
        expected = Window.HEIGHT - test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y += 150
        test_car2 = Player(pygame.sprite.LayeredUpdates())
        test_net_group.add(test_car2)
        test_car2.rect.x = test_player.rect.x
        test_car2.rect.y = test_player.rect.y + 50
        expected = test_car2.rect.y - test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x = test_player.rect.x
        test_car.rect.y = Window.HEIGHT - test_car.rect.height
        expected = test_car2.rect.y - test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("down", test_net_group)
        self.assertEqual(expected, actual)
    def test_find_distance_to_right_sprite(self):
        test_player = Player(pygame.sprite.LayeredUpdates())
        test_net_group = pygame.sprite.Group()
        test_car = Player(pygame.sprite.LayeredUpdates())

        expected = Window.WIDTH - test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        # Move the test car to the right side of the player
        test_car.rect.y = test_player.rect.y
        test_car.rect.x = test_player.rect.x + 50
        test_car.add(test_net_group)

        expected = test_car.rect.x - test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y += 10
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y -= 10
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y -= 1000
        expected = Window.WIDTH - test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x -= 150
        test_car2 = Player(pygame.sprite.LayeredUpdates())
        test_net_group.add(test_car2)
        test_car2.rect.y = test_player.rect.y
        test_car2.rect.x = test_player.rect.x + 50
        expected = test_car2.rect.x - test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y = test_player.rect.y
        test_car.rect.x = Window.WIDTH
        expected = test_car2.rect.x - test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("right", test_net_group)
        self.assertEqual(expected, actual)
    def test_find_distance_to_left_sprite(self):
        test_player = Player(pygame.sprite.LayeredUpdates())
        test_net_group = pygame.sprite.Group()
        test_car = Player(pygame.sprite.LayeredUpdates())

        expected = test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        # Move the test car to the left side of the player
        test_car.rect.y = test_player.rect.y
        test_car.rect.x = test_player.rect.x - 50
        test_car.add(test_net_group)

        expected = test_player.rect.center[0] - (test_car.rect.x + test_car.rect.width)
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y += 10
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y -= 10
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y -= 1000
        expected = test_player.rect.center[0]
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x += 150
        test_car2 = Player(pygame.sprite.LayeredUpdates())
        test_net_group.add(test_car2)
        test_car2.rect.y = test_player.rect.y
        test_car2.rect.x = test_player.rect.x - 50
        expected = test_player.rect.center[0] - (test_car2.rect.x + test_car.rect.width)
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.y = test_player.rect.y
        test_car.rect.x = 0
        expected = test_player.rect.center[0] - (test_car2.rect.x + test_car.rect.width)
        actual = test_player.find_distance_to_sprite("left", test_net_group)
        self.assertEqual(expected, actual)
    def test_find_distance_to_sprite_ahead(self):
        test_player = Player(pygame.sprite.LayeredUpdates())
        test_net_group = pygame.sprite.Group()
        test_car = Player(pygame.sprite.LayeredUpdates())

        expected = test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        # Move the test car in front of the player
        test_car.rect.x = test_player.rect.x
        test_car.rect.y = test_player.rect.y - 50
        test_net_group.add(test_car)

        expected = test_player.rect.center[1] - test_car.rect.y
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x -= 10
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x += 20
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x += 1000
        expected = test_player.rect.center[1]
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        test_car2 = Player(pygame.sprite.LayeredUpdates())
        test_net_group.add(test_car2)
        test_car.rect.y += 150
        test_car2.rect.x = test_player.rect.x
        test_car2.rect.y = test_player.rect.y - 50
        expected = test_player.rect.center[1] - test_car2.rect.y
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)

        test_car.rect.x = test_player.rect.x
        test_car.rect.y = 0
        actual = test_player.find_distance_to_sprite("ahead", test_net_group)
        self.assertEqual(expected, actual)