螺旋状の弾幕の作り方
Posted: 2020年6月25日(木) 11:24
現在Visual Sturdyで東方弾幕シューティングに出てくるような弾幕を制作しているのですが
螺旋状に広がっていく弾の作り方が分からないので教えてください。
下のソースは広がりながら一定の場所まで行くと弾を出したところに戻ってくるみたいなやつを作りました。
これを少しいじって螺旋状にしたいと考えています。
static const float FLOOR_Y = WINDOW_HEIGHT - 100.0f; // 床座標
// 出現パラメーター
// パーティクルパラメーター
static const int PIECE_MAX = 100; // パーティクルの総数
bool active[PIECE_MAX]; // 今使っているならtrue, 使ってなければfalse
int lifeTime[PIECE_MAX]; // ピースが出現している時間
float positionX[PIECE_MAX]; // 座標
float positionY[PIECE_MAX];
float velocityX[PIECE_MAX]; // 速度
float velocityY[PIECE_MAX];
static const int SPAWN_COUNT = 5;//1フレームに出現する数
//static const int LIFE_MAX = 120; //生きている時間
int timeCount;//出現時間数える
int PieceMove;
int pieceImage = -1;
float r;//円の半径(展開範囲)
float ang = 0.0f;
void EffectInit()
{
// 画像の準備
pieceImage = LoadGraph("data\\texture\\bullet2.png");
r = 20.0f;
PieceMove = 0;
// データを
for (int i = 0; i < PIECE_MAX; i++) {
active = true;
positionX = 400.0f;
positionY = 300.0f;
velocityX = 0.0f;
velocityY = 0.0f;
lifeTime = 0;
}
}
void EffectUpdate()
{
if (PieceMove <= 300) {
PieceMove += 1;
r += 0.5f;
ang += 0.05f;
}else if(PieceMove <= 350){
r -= 0.5f;
ang -= 0.05f;
}
for (int i = 0; i < PIECE_MAX; i++) {
positionX = r * cos(DX_PI / 18 * i + ang) + 400.0f;
positionY = r * sin(DX_PI / 18 * i + ang) + 300.0f;
}
/*for (int i = 0; 250 > PIECE_MAX; i++) {
positionX = r * cos(DX_PI / 18 * i - ang) - 400.0f;
positionY = r * sin(DX_PI / 18 * i - ang) - 300.0f;
}*/
}
void EffectDraw()
{
for (int i = 0; i < PIECE_MAX; i++) {
if(active[i])
DrawRectGraph(positionX[i], positionY[i], 0, 32, 32, 32, pieceImage, true, false);
}
}
void EffectRelease()
{
DeleteGraph(pieceImage);
pieceImage = -1;
}
螺旋状に広がっていく弾の作り方が分からないので教えてください。
下のソースは広がりながら一定の場所まで行くと弾を出したところに戻ってくるみたいなやつを作りました。
これを少しいじって螺旋状にしたいと考えています。
static const float FLOOR_Y = WINDOW_HEIGHT - 100.0f; // 床座標
// 出現パラメーター
// パーティクルパラメーター
static const int PIECE_MAX = 100; // パーティクルの総数
bool active[PIECE_MAX]; // 今使っているならtrue, 使ってなければfalse
int lifeTime[PIECE_MAX]; // ピースが出現している時間
float positionX[PIECE_MAX]; // 座標
float positionY[PIECE_MAX];
float velocityX[PIECE_MAX]; // 速度
float velocityY[PIECE_MAX];
static const int SPAWN_COUNT = 5;//1フレームに出現する数
//static const int LIFE_MAX = 120; //生きている時間
int timeCount;//出現時間数える
int PieceMove;
int pieceImage = -1;
float r;//円の半径(展開範囲)
float ang = 0.0f;
void EffectInit()
{
// 画像の準備
pieceImage = LoadGraph("data\\texture\\bullet2.png");
r = 20.0f;
PieceMove = 0;
// データを
for (int i = 0; i < PIECE_MAX; i++) {
active = true;
positionX = 400.0f;
positionY = 300.0f;
velocityX = 0.0f;
velocityY = 0.0f;
lifeTime = 0;
}
}
void EffectUpdate()
{
if (PieceMove <= 300) {
PieceMove += 1;
r += 0.5f;
ang += 0.05f;
}else if(PieceMove <= 350){
r -= 0.5f;
ang -= 0.05f;
}
for (int i = 0; i < PIECE_MAX; i++) {
positionX = r * cos(DX_PI / 18 * i + ang) + 400.0f;
positionY = r * sin(DX_PI / 18 * i + ang) + 300.0f;
}
/*for (int i = 0; 250 > PIECE_MAX; i++) {
positionX = r * cos(DX_PI / 18 * i - ang) - 400.0f;
positionY = r * sin(DX_PI / 18 * i - ang) - 300.0f;
}*/
}
void EffectDraw()
{
for (int i = 0; i < PIECE_MAX; i++) {
if(active[i])
DrawRectGraph(positionX[i], positionY[i], 0, 32, 32, 32, pieceImage, true, false);
}
}
void EffectRelease()
{
DeleteGraph(pieceImage);
pieceImage = -1;
}