How to make a circle orbit a touch point

@athros woah, sounds pretty awesome! You should keep me updated :stuck_out_tongue:

@Monkeyman32123 There isnā€™t anything wrong with yours. I was just pointing out that there were other orbit programs on the forum. No matter how much I know, if I look at someone elseā€™s code, I always learn something new.

I guess there are as many ways to orbit a planet as there are planets. :slight_smile:

Here is another version using Codea rotate and translate. In this way you can rotate a moon with a moon around a planet. I leave it as a challenge to modify it so that the moons dont collide. :slight_smile:

function setup()
    displayMode(FULLSCREEN)
end

function draw()
    background(40, 40, 50)

    translate(CurrentTouch.x, CurrentTouch.y)
    math.randomseed(1)
    
    for i = 1,10 do
        rotate(math.random(0,360) + -- start angle
               math.random(30,90)*ElapsedTime) -- rotation speed
        sprite("SpaceCute:Planet",0,0,100)
        translate(200,0) -- distance to planet
        scale(.6) -- size of moon
    end   
end

@dave1707 If every time you look at someoneā€™s code you learn something new, then when are you going to learn about local? :wink:

@SkyTheCoder I know about locals and what itā€™s used for. I just donā€™t need it in the code I write. Someone else might need locals if they take my code and try to use it in their code. Then theyā€™ll need to learn about locals.