パスアニメーションのような感じで、弾1つ1つをサイングラフの軌道に動かせば組めると思うのですが、組み方が全く思いつかないため、どなたかアドバイスをお願いします。
例として、直線に発射する弾幕のサンプルを載せます。
header
#include"AbstractBossShotPattern.h"
class BossShotPattern008 : public AbstractBossShotPattern
{
public:
BossShotPattern008(const GameScene& gameScene);
virtual ~BossShotPattern008(void) = default;
void draw(void) const override {}
void shotUpdate(GameScene& gameScene, BossBulletManager& shot, Boss& boss, Player& player) override;
private:
const int _TM000 = 120;
float _shotAngle;
float _shotAngleRate;
float _shotSpeed;
int _time;
float _vx, _vy;
};
using namespace std;
BossShotPattern008::BossShotPattern008(const GameScene& gameScene) :
AbstractBossShotPattern(gameScene),
_shotAngle(Define::PI / 4.0f),
_shotAngleRate(0.0f),
_shotSpeed(2.0f),
_time(0),
_vx(0.0f),
_vy(0.0f)
{
}
void BossShotPattern008::shotUpdate(GameScene& gameScene, BossBulletManager& shot, Boss& boss, Player& player)
{
_time = boss.getShotCounter() % _TM000;
int time = boss.getShotCounter();
if (_time == 0)
{
//引数:X座標, Y座標, 角度, スピード, 弾の種類, 弾の色, 弾の状態
shot.getBullet().emplace_back(make_shared<BossBullet>(
boss.getX(),
boss.getY(),
0.0f,
0.0f,
EnemyBulletImage::getIns()->eKodama,
EnemyBulletImage::getIns()->eBlue,
0
)
);
}
// 弾の移動処理をコンストラクタではなく、直接ここに計算している。
_vx = cosf(_shotAngle) * _shotSpeed;
_vy = sinf(_shotAngle) * _shotSpeed;
for (int i = 0; i < shot.getBullet().size(); i++)
{
shot.getBullet()[i]->setX(shot.getBullet()[i]->getX() + _vx);
shot.getBullet()[i]->setY(shot.getBullet()[i]->getY() + _vy);
}
}