I'm currently stuck with my game, which is from the top perspective. I'm currently using these sprites for player: (using the second at the top):
And here's what I use for my gun
My problem is that I am not sure how to calculate origin & position to make sure that gun is always in player's hands. This is my code for drawing player and gun
spriteBatch.Draw(Textures.Load("player"), new Vector2(playerPosition.X, playerPosition.Y), new Rectangle(35, 2, 27,27), Color.White, player.rotation, new Vector2(playerWidth / 2, playerHeight / 2), 1f, SpriteEffects.None, 1f);
spriteBatch.Draw(Textures.Load("Guns/deagle"), new Vector2(playerPosition.X, playerPosition.Y), null, Color.White, player.rotation, new Vector2(playerWidth / 2, playerHeight / 2), 1f, SpriteEffects.None, 1f);
With rotation of 0, I'd need to move my gun to playerPosition.Y + 15
to make sure gun is in guy's hands, but when I do it, it looks fine but as soon as I rotate him, it's even more weird than now.
Here's how it currently looks like, with my specified code above.
https://dl-web.dropbox.com/get/capture-14.mp4?w=40052a2d
All I need is to make sure that gun will be always in guy's hands
Vector2 direction = new Vector2(player.x, player.y) - new Vector2(worldPosition.X, worldPosition.Y);player.rotation = (float)(Math.Atan2(direction.Y, direction.X))
. If I had it the way you described, I had to add 180 degrees to the rotation \$\endgroup\$