blast_shape

Blasts a shape of projectiles outwards from a point.

 Script

/****************************************************************************************
blast_shape(centerX,centerY,angle,edgeCount,pointsPerEdge,speed,projectile,starMode);
****Arguments:
centerX - X coordinate of blast center
centerY - X coordinate of blast center
angle -  Angle (of rightmost vertex) in degrees
edgeCount - Number of edges (3=triangle, 4=square, etc)
pointsPerEdge - Points per edge (each edge is divided equally into argument3-1 segments, and a point is placed at those divisions)
speed - Speed of explosion
projectile - object index of projectile (deliciousFruit, for example)
starMode - Star mode: false for regular shapes, true for stars (only works for odd numbers of edges)

****Example usage:
blast_shape(x,y,0,3,6,5,deliciousFruit,false)
blasts a triangle from current position, 3*6=18 cherries in total, with speed 5

blast_shape(x,y,0,5,6,5,deliciousFruit,true)
blasts a 5-pointed star from the current position, 5*6=30 cherries in total, with speed 5
***************************************************************************************/

var th, xx, yy, ddx, ddy, dx, dy, a, inc;

th=degtorad(argument2);

if (argument6==0) argument6=deliciousFruit; //replace deliciousFruit with the default cherry object in your engine

if (argument7) inc=2;
else inc=1;

//Define the Vertices
for (i=0;i<=argument3*inc;i+=1) {
    xx[i]=cos(th + 2*pi * i/argument3);
    yy[i]=sin(th + 2*pi * i/argument3);
}

//For each edge
for (i=0;i<argument3*inc;i+=inc) {
    //edge length
    ddx = xx[i+inc]-xx[i];
    ddy = yy[i+inc]-yy[i];
    //For each point along the edge
    for(j=0;j<argument4;j+=1) {
        //distance from first point to this point
        dx=xx[i]+ddx*j/argument4;
        dy=yy[i]+ddy*j/argument4;
        //Fire a cherry
        a=instance_create(argument0+dx,argument1+dy,argument6);
        a.direction=point_direction(0,0,dx,dy);
        a.speed=argument5*point_distance(0,0,dx,dy);
    }
}