Hi guys, I try to make a ship shoot a bullet toward a mouse position with this code
float deltaX = mousePosition.x - (aircraft.getPosition().x + aircraft.getLocalBounds().width / 2);
float deltaY = mousePosition.y - (aircraft.getPosition().y + aircraft.getLocalBounds().height / 2);
float angleRadian = (float)(std::atan2(deltaY, deltaX));
float angleDegree = (float)(angleRadian * 180 / PI);
It works fine with one bullet but when I add another bullet I can't figure out how to calculate the start position for each bullets.
This is a picture of this problem.
I try to specify start position of each bullets by this code.
sf::Vector2f offset1(aircraft.getPosition());
offset1.x += -10;//start shooting point for first bullet.
sf::Vector2f offset2(aircraft.getPosition());
offset2.x += 10;//start shooting point for second bullet.
But when I rotate the ship to other angles the bullets are not the same as the first picture.
How can I calculate the start position of each bullets?