I am trying to make a planet appear to be rotating on an axis parallel to the plane of the screen (2d game). I have a 5000 x 5000 pixel texture of randomly generated continents/oceans (
here is a smaller example. imgur wont let me upload the big one. For each planet I choose a random point on this texture and set the texture rect at this position and the width/height to the diameter of the planet.
Here is a drawing to help visualize what I am trying to do and
here is a gif of what I have achieved so far but it isn't quite right. In the image, I want the texture rect to translate around the larger circle in a small amount each frame. As for the gif, I honestly have no clue what is causing that stretching stuff as there is nothing like that in the texture. It is possible that it is going out of the bounds of the texture because i don't check for that yet. Any help is appreciated.
Here is the code after setting the texture rect and radius of the circle,
//this is the radius of the larger circle that the texture rect will move along
bigRadius = (std::sqrt(2.0) + 1) * circle.getRadius() - circle.getRadius();
//origin of the circle is set to the center of the circle. this is the point we want to translate (circle is the planets circleshape)
point = circle.getPosition();
//point we want to translate around
centerPoint.x = circle.getPosition().x;
centerPoint.y = circle.getPosition().y + bigRadius;
Here is my update function (angle is initialized to 0)
angle += .1;
float sin = std::sin(angle * DEGTORAD);
float cos = std::cos(angle * DEGTORAD);
point.x = centerPoint.x * cos - centerPoint.y * sin;
point.y = centerPoint.x * sin + centerPoint.y * cos;
circle.setTextureRect(sf::IntRect(point.x - circle.getRadius(), point.y - circle.getRadius(), circle.getTextureRect().width, circle.getTextureRect().height));
If you watch the gif closely, you can see that the translation is kind of working but I don't know what to do to make it work completely. I also know this is not exactly parallel to the plane of the screen but this is the best I could come up with. Anybody have any ideas?