so I have been making a space related game and m trying to figure out how to make the “moon” sprite to orbit the “earth” sprite while also moving with the earth sprite if you move the earth sprite if you want or need to here is my game (it is not done and most of the code is not placed down yet) at the start it is a player select so idk if that will make it harder or not.
You should be able to use Cos and Sin math functions to make the sprite orbit. Cos and Sin take in a variable and output a variable. The input is the rotation in radians, and the output is the x/y position of a point around a circle with radius 1. Cos is x, Sin is y. Basically, you would have a variable like “rotation” and in a forever loop you can set the moon sprite position like
Set moon.x = earth.x + (multiplier • Cos(rotation) )
Set moon.y = earth.y + (multiplier • Sin(rotation) )
The “multiplier” is the distance from the earth you want it to rotate. Since rotation in radians means 360 degrees is the same as 2pi, every frame you should be increasing the rotation variable by a very small amount, like 0.05 or something. That way the orbit is slow.
You could try the sprite utils extension, it allows you to place sprites a distance and angle from another sprite. It can also do a bunch of other stuff. Hope that helps