0
\$\begingroup\$

There are two controllable objects orbiting around a centre block. Unfortunately, I don't really know how to stick them so they can only move around the block (left/a sends them clockwise, right/a sends them anti-clockwise) and can only get them to move like normal sprites not on a set path.

I haven't got any code to show yet, but I could really appreciate either some advice, or preferably some examples.

\$\endgroup\$
0
\$\begingroup\$

consider constant velocity for a simplier explaination.

in a linear movement you would calculate each frame's delta position depending on your velocity and adjust your object location adding the result.

ds = v * dt

in a circular movement things are quite the same but you have to calculate delta angle based on your angular velocity.

dϕ = ω * dt

compute your new position with

p = (x = cosϕ * r, y= sinϕ * r)

given r the distance of your object from the center of the circle

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.