Target Detection Algorithm

targeting-computer-algorithmIn star wars movies, most spaceships are fitted with laser cannons to shoot enemy spaceships. To assist the pilot, these spaceships have built-in targeting computers that enable them to aim the cannon and inform them when their target is within reach. When this is the case, the algorithm inform the pilot with the following message:

target-acquired

We have retrieved the code used in a Star Wars Tie Fighter spaceship. The code is used to aim the laser cannon. However this spaceship is not fitted with a target acquisition algorithm to inform the pilot when to shoot.

star-wars-spaceship

Your aim is to upgrade this code to detect when the enemy spaceship is within reach of the laser cannon.

To do so you will need to check if the X, Y coordinates of the cannon aim (mouse pointer) is within the A B C triangle representing the enemy spaceship:
target-acquired-coordinates

Python Code


Your aim is to upgrade this code from line 60 to detect when the enemy spaceship is within reach of the laser cannon:

Share Button