First of all, sorry! This will probably be a solution with a terrible amount of math in it.

At least you get an image

I want the projectiles to spawn at the end of the gun-barrel. Each gun has an offset calculated from its attachments (silencer etc.) and the basic gun-length.How would I go about figuring out the spawnpoint for the projectiles when I rotate the arms?

Note: good time to check out image before continuing

I was thinking I could save a variable with a fixed point in the gun-class (the calculation in bold above) for when it's pointing directly right, so I know how long the gun is at all times. But with a rotation around an anchor, I can't just use circle-calculations.

I might also just rotate around the top-left, and somehow calculate the offset between the shoulder-point and the junction-point on the rotated image, but how?

Have any of you guys done this before? Any suggestions? Maybe there's some other way of doing the rotation of the arms and gun that would work, and still make sure they're in the right place at his shoulders.

Note: This is using nothing but Java2D. I know. Next project I'll use LWJGL

If you're using LWJGL, you could send the bullet through the same Matrix settings as the rotated arms, then do like the guy above said and draw an actual line in the matrix the entities are in to calculate the actual collision.

There's probably a better way to do it though, I'm not much of a pro with platform-game technique.

I've seen so many games using similar techniques to have rotating arms and the projectiles spawn right at the end of the gun. I'm really stumped on this one. Any suggestions as to what I have to read up on? I'm guessing there'll be a some vector-calculations, mixed with radians and such, but I just can't seem to wrap my head around it. How do they do it?

You have an offset (vector) from the anchor point to the tip of the weapon. It rotates exactly with the image.

How do you mean? If I draw the weapon and arms on an image for themselves, and I know the exact offset from shoulder-point to projectile-spawn point when it is pointing directly to the right, how would I calculate where the new projectile-spawn point is after using an AffineTransform to rotate it? I don't understand how that initial projectile-spawn point can be changed to match the new spot it is supposed to be on, after the image has been rotated.

Do I create a vector from shoulder-point to projectile-spawn point, and run that through the same AffineTransform? And how would I do that? I don't think I can "attach" an AffineTransform to a Vector or Point

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org