I have a line perpetually pointed at the mouse and originating at the player, but the length is limited to a certain value.
I also can create a circular object on demand in Box2D (specifically the love2d bindings). I would like to apply an impulse on the new object that will send it flying in the direction of the line, with force proportional to the length of the line (that specific proportion is not important). The object should not roll along that line like a cannonball in a cannon barrel, but it should begin its journey in the direction of the line, such that a user can intuitively direct the projectile (all my attempts* at solving this issue have led to some angles (45/135) having similar projectile directions as flat angles (0/180), which means the angle is not functional as an aiming mechanism). I suppose a successful implementation might look like this:
I have been looking through tutorials and haven't found an answer. I see whisperings of ways to do it by simply supplying the angle (if I read the pages correctly) but Love2D's function does not support that.
The way in Love2D to apply a linear impulse is
Body:applyLinearImpulse( ix, iy, x, y ) with ix and iy being the x and y components of the impulse, and x and y being the position to apply the impulse (default to origin of body).
*The best I have tried is to apply the distance of the line as the x/y components in
applyLinearImpulse. This creates the awful failure I mentioned earlier where the angle of the line does not produce much difference in the angle of the projectile (but it does produce a tiny amount, with extremely diminishing returns as the line approaches a 90 degree angle / vertical line).