Circular Bullet Spread not Even
Posted
by
SoulBeaver
on Game Development
See other posts from Game Development
or by SoulBeaver
Published on 2011-11-13T12:55:14Z
Indexed on
2011/11/13
18:06 UTC
Read the original article
Hit count: 408
I'm creating a bullet shooter much in the style of Touhou. Right now I want to have a very simple circular shot being fired from the enemy.
See this picture:
As you can see, the spacing is very uneven, which isn't very good if you want to survive.
The code I'm using is this:
private function shoot() : void
{
const BULLETS_PER_WAVE : int = 72;
var interval : Number = BULLETS_PER_WAVE / 360;
for (var i : int = 0; i < BULLETS_PER_WAVE; ++i
{
var xSpeed : Number = GameConstants.BULLET_NORMAL_SPEED_X * Math.sin(i * interval);
var ySpeed : Number = GameConstants.BULLET_NORMAL_SPEED_Y * Math.cos(i * interval);
BulletFactory.createNormalBullet(bulletColor_, alice_.center, xSpeed, ySpeed);
}
canShoot_ = false;
cooldownTimer_.start();
}
I imagine my mistake is in the sin, cos functions, but I'm not entirely sure what's wrong.
© Game Development or respective owner