I'm trying to make a shmup and trying to make a specific "bullet pattern". Basically, I have an enemy fire a number of bullets displaced around a circle. Let's say that that circle of bullets is going to the right. Next, I want the circle to collapse upon itself so I add a second impulse to the x & y velocities of the bullet. Essentially so that the shape of the bullets being fired looks something like this as it travels (I hope this shoddy symbolization makes sense):
O o • o O
That works.
Then I just want it to collapse it's vertical positioning, not horizontally so it would look like this:
O — O
I can also do this. BUT, if I try to shoot this circle diagonally, or in a direction other than perfectly horizontally or vertically it breaks down a bit.
Here is the code I'm working with, the section with clusterGrowthX & Y is the part i'm having trouble with. The solution is probably staring me right in the face but I can't figure it out right now. Any questions, just ask. Thanks.
for(var j:int = 0; j < _info.clusterAmount; j++)
{
var around : Number = _info.angle - (_info.clusterRange/2) + (_info.clusterRange/_info.clusterAmount/2) + j * (_info.clusterRange/_info.clusterAmount);
var xOff : Number = (Math.cos(around) * _info.clusterRadius);
var yOff : Number = (Math.sin(around) * _info.clusterRadius);
var bullet = new _info.bulletShape(_info);
bullet.x = startPoint.x + xOff;
bullet.y = startPoint.y + yOff;
if(_info.dParent is PlayerControl)
{
bullet.x += Math.cos(_info.angle) * 40;
bullet.y += Math.sin(_info.angle) * 40;
}
var sign : Number = (_info.angle < 0) ? -1 : 1;
trace(Math.cos(around),Math.sin(around));
bullet.info.vx += Math.cos(around) * _info.clusterGrowthX;
bullet.info.vy += Math.sin(around) * _info.clusterGrowthY;
bullet.rotation = _info.angle * 180 / Math.PI;
_info.dLevel.addChild(bullet);
}