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 informs 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:


unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!