Hello,
Firstly, I am no professional or aspiring programmer, simply a High School student with a passion for making and selling simple calculator games during math class.. So please forgive my limited technical expertise! I will be happy to answer any questions about the code or how the game is set up.
I am currently working on a game called "Ships", where you navigate two points that form a line (representing a ship) across the screen and try to sink AI ships (also lines navigating the screen).
I have the "cannonball" as a point that travels perpendicular from your line until it either reaches the edge of the screen or "hits" the AI line.
I am able to make the cannonball (simply two variables representing x and y coordinates) travel away from a line using a repeat loop, however am having trouble creating conditions to exit the loop when the ball coordinates are at the AI Ship.
So my question is, how could I make a condition that returns true when the cannonball is either:
- On the line between two points
- Within a box connecting the two end points of the line
- Within a circle with a center at the midpoint of the line and a radius of 5 (the ship is 10 units long)
I give you my many thanks in advance.. This issue has been troubling me for quite a few days now.
-Jack
As clarification, Here is an ASCII sketch of the game and it's simplicity.
you (A)
/ (C)
/ * ball \ AI
(B) (D)