Is there a way I can make an object move in a circle around the center of the world at any speed (changeable int)?


1 2 3 4 5 6 7 8 9 10 | int rotationalSpeed = 1 ; int radius = 200 ; // adjust as needed public void orbitWorldCenter() { setLocation(getWorld().getWidth()/ 2 , getWorld().getHeight()/ 2 ); turn(rotationalSpeed- 90 ); move(radius); turn( 90 ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | public void act() { int cx = getWorld().getWidth()/ 2 ; int cy = getWorld().getHeight()/ 2 ; int speed= 5 ; turnTowards(cx,cy); int rotation = getRotation(); setRotation(rotation + 89 ); move (speed); } |