285
« on: August 03, 2015, 04:49:28 PM »
A while back sand wrote this script for orbiting, I hope he won't mind I put it here:
argument0=centerX; //the center x-coordinate for the orbit
argument1=centerY; //the center y-coordinate for the orbit
argument2=radius;
argument3=spinSpeed; //the speed the projectile is moving in the orbit
argument4=direction;
argument5=radiusSpeed; //the speed the projectile is moving along the radius (a speed of -1 would make the projectile move inwards)
x=centerX+lengthdir_x(radius+rad,direction+dir);
y=centerY+lengthdir_y(radius+rad,direction+dir);
dir+=spinSpeed;
rad+=radiusSpeed;
And in the projectile's step event:
orbit(centerX,centerY,radius,spinSpeed,direction,radiusSpeed);
You could set the defaults in the projectile's step event, but for me, when I set the spinSpeed in the step event, the projectiles will just speed up until it hits a certain speed, then slow back down, as if it were a sine wave. To avoid this, I usually just put in either a spawning object's alarm[_] event or the boss's alarm[_] event:
for(i=0;i<360;i+=360/[number]){
a=instance_create([x value],[y value],cherry);
a.centerX=a.xstart;
a.centerY=a.ystart;
a.radius=[number];
a.spinSpeed=[number];
a.direction=i;
a.radiusSpeed=[number];
}
If you don't want the projectiles to move in towards the orbit's center, you can remove rad and radiusSpeed from each code or just set it radiusSpeed to 0.