Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

Illustration of the issue
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?

share|improve this question
1  
I don't understand. Why are you doing this instead of just plain AABB collision detection? Are you just asking how to find the intersection between a ray and a bezier curve? –  Anko Mar 12 at 13:12
    
+1 for Anko. This seems like a sledgehammer to crack a nut. If the only goal is to find collisions between the bullets and the enemies, then there are much more simple ways to do it. –  Laurent Couvidou Mar 12 at 20:34
    
Okay, I think you're right. It is a bit too ambitious for what I'm trying to do, and I came up with a much easier solution using the plain AABB collision method. I'm sorry, but I'm very new to this –  user1974555 Mar 13 at 6:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.