Jump to content

Photo

Circular Movement

FFC

  • This topic is locked This topic is locked
No replies to this topic

#1 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Gender:Female
  • Location:Rainbow Factory

Posted 13 December 2013 - 02:35 PM

Circular Motion

 
Description
 
This script allows for a freeform combo to move in a circular pattern. This can also be made into an oval and rotated at the center.
 
Screenshots and Demo
 
rotated_ellipse.gif
 
Code
 
//Include this line once at the top of your script file.
import "std.zh"
 
ffc script CircularMotion
{
    void run(int radius, int speed, int angle, int radius2, int angle2)
    {
        if(radius2 == 0) radius2 = radius; //Circle
        if(angle < 0) angle = Rand(360); //Random Start
        int cx = this->X;
        int cy = this->Y;
        while(true)
        {
            angle += speed;
            if(angle < -360)angle+=360; //Wrap if below -360.
            else if(angle > 360)angle-=360; //Wrap if above 360.
            if(angle2==0)
            {
                this->X = cx + radius*Cos(angle);
                this->Y = cy + radius2*Sin(angle);
            }
            else //Rotate at center.
            {
                this->X = cx + radius*Cos(angle)*Cos(angle2) - radius2*Sin(angle)*Sin(angle2);
                this->Y = cy + radius2*Sin(angle)*Cos(angle2) + radius*Cos(angle)*Sin(angle2);
            }
            Waitframe();
        }
    }
}
 
Setup
 
Place the ffc at it's center and set it's attributes as follows. D3 and D4 are optional.
  • D0: radius in pixels.
  • D1: speed of rotation in degrees.
  • D2: starting position in degrees. If negative it will be random.
  • D3: radius2, this is used for the Y Axis, if set it will turn into a oval.
  • D4: angle2, this will cause the oval to be rotated at it's center like in the picture above.
Resources
 
Requires std.zh which is included with ZC.




Also tagged with one or more of these keywords: FFC

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users