I'm fairly new to game logics, C#/XNA (The language/library of choice) and bezier curves in general, and is stuck in my current project. I'm going to try to explain as thoroughly as I can what the issue at hand is.
The illustration above shows a line (P/Player) and three cubic bezier curves (A/B/C = "Enemies") between the time interval 0 ≤ t ≤ 1.
When the player holds down the right arrowkey, the player will move in a linear path to the right accordingly to a time variable (t). If the player also holds down the "fire button", the player character will shoot out bullets with a width of about 5 px from the top of it.
If the engine I have in mind is going to work, I will have to know precisely for how long period of time the enemies moving in their cubic bezier curves are being exposed to these bullets being shot out of the player. E.g. during the timespan of 0 ≤ t ≤ 1, enemy A will be exposed to bullets for a total of 0.43 units, B = 0.27 and C = 0 (these are made up results)
Which would be the most efficient and best way to take on this issue? So far I'm thinking of solving it by finding out the roots of the intersection of the line and the curve on the X-Axis to know if the players bullets will make contact during the timespan. But even if they do make contact, how can I make sure which enemy the player hits if the enemies paths kind of "overlap" eachother (like A and B in the picture)?
Some facts about the bullets that could clarify the behavior of the bullets I have in mind:
- Bullets can't penetrate enemies. When it hits it's first target, it does not affect the one's behind it
- For now, I'm satisfied if someone could come up with a solution without "bullet travel time" in mind. That the bullets hits instantly doesn't bother me too much. Bonus points if "travel time" is added in the solution of course.
- In the picture, I show two lines. I would like to be able to multiple bullets being able to fire from different starting points on the player (like a dual-shot, quad-shot ect).
To sum my question up: (Quick reference guide)
When player goes to the right within 0 ≤ t ≤ 1, for how long does the player's bullets collide with the enemies?