Pages: 1
Topic closed
I drew a circle, radius 100 and centered at (0,0) and would like to have a sprite keep circling the circumference of my circle. With calculations rounded to two decimal points I was able to do it using a combination of the "turn 0.58 degrees" and "take 1 step" but over time I'm sure the moon's orbit would gradually shift. Is there a way to make a *formula* control the motion? The formula might be x^2 + y^2 = 10,000, but how do you make it *control* the movement? If it's possible at all, I'd appreciate advice! :-)
Offline
This project seems to have what you are looking for.
http://scratch.mit.edu/projects/archmage/52542
Just get rid of the jump feature in the cat and make it so that you don't have to press an arrow key to move.
The script to make it rotate around whatever it is pointing at is
forever{
point to (target)
change x by (sin of (direction-90))
change y by (cos of (direction-90))
}
Also remember, scratch isn't too accurate so even with the proper formulas it may mess up.
Last edited by archmage (2009-08-18 15:51:58)
Offline
Your script works fine! And your "Ruler of the world" project is amazing. You mentioned that the Scratch math might not be totally accurate and, sure enough, I noticed that the Moon circling my Planet gradually spiraled farther out. But it seems much better to use a formula to control motion like this than the "move" strategy I'd pieced together. Thanks so much for your help. I would never have been able to use trig functions to do anything.
Offline
You could also get rid of all the math and just set the circling sprite's rotation point somewhere outside of its costume (at the distance of the circle's radius), then align the rotation point with the center of your circle and merely "turn" your sprite
Offline
Jens wrote:
You could also get rid of all the math and just set the circling sprite's rotation point somewhere outside of its costume (at the distance of the circle's radius), then align the rotation point with the center of your circle and merely "turn" your sprite
![]()
Brilliant, Jens! Thanks. I used the math approach and there was slow deviation. Same with my earlier "move" approach. So now I'll try this.
Offline
Topic closed
Pages: 1