Fangames > Programming Questions

Make cherry move in Archimedian spiral with constant speed?

<< < (2/3) > >>

zaphod77:
The radiuspeed script wont' work. the cherry doesn't move at a constant speed.

the ratio one above does the trick for spiraling out.

but i want to also be able to spiral IN, starting at the spawn point.

infern0man1:
I'm not sure what you mean by that then. With what I did, you create a cherry with a radius of, say, 800 pixels, from a central point that you define, meaning the cherry is 800 pixels away from it's central point; the cherry will always move into where you set it's centerX and centerY (the central point), which, with what I did, is where it spawned from originally, and the cherry will also rotate around the central point without making the cherry go off its path toward its central point.

If that's not what you want then I have no idea what you want.

zaphod77:
No i want it to start at the spawn point, and based on the spiral factor, work out where the center point should be and spiral in towards that.

infern0man1:

--- Quote from: zaphod77 on January 20, 2016, 05:20:39 PM ---The radiuspeed script wont' work. the cherry doesn't move at a constant speed.

--- End quote ---


I'm thinking you might have done something wrong in setting it up, because that's not what is supposed to happen. Whatever though, that isn't what you want so I'll stop posting in here.

zaphod77:
Yeah i probably screwed something up.

your approach uses a function to spawn the object and then control it.

My approach is to spawn the object, then change the variables inside it to make it go.

a=instance_create(x,y,objSpiralCherry);
a.direction=0;
a.spiral_factor=10; // variable defined to 0 by default in create event.
a.speed=5;

and off it goes.

this DOES work with the ratio formula fine as i posted above, but i've only been able to get outward spirals. i've tried to make it move the opposite direction by adding 180, but all that does is rotate the outward spiral itself.

Okay i'm completely puzzled.

I've tried manually setting the center, and no matter WHAT i do, it somehow snaps onto a spiral, and then spirals outwards! i've tried negative speed (that just rotates the spiral 180), i've tried adding 180 to the directions (whihc does the same thing), but absolutely nothing works.  the object always snaps onto a spiral going out. if i multiply the direction by negative 1, i get clockwise instead of counter clockwise.

if the spiral factor is too big for the speed (higher speeds need smaller spiral factors), it starts jittering, but still overall follows an outward spiral.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version