Using C++ and SFML. I have three entities. We will call them the Sun, the Earth, and the Moon.
First up, the sun, non-moving at all. Second, the earth, rotating around the sun, this seems to work just fine. Lastly, the moon, which does keep in rotation to a point but seems to be doing a large oval around the earth instead of doing a generic rotation around it. When I actually stop the earth from rotating, the moon rotates fine.
I am assuming that the earth position changing is effecting how the moon should rotate.
sf::Transform rotation;
rotation.rotate(mOrbitSpeed * dt.asSeconds(), mParent->getPosition());
sf::Vector2f positionAfterRotation = rotation.transformPoint(getPosition());
setPosition(positionAfterRotation);
The origin of the planets are set to the middle, I.E. so getPosition() gets the center of the planet as well. Get position returns the x and y coordinates. mParent would be the orbiting parent (I.E. Sun for Earth.)
Any suggestions? Thanks!