弾幕の作成について
Posted: 2011年10月07日(金) 04:49
こんにちは。いつもお世話になっております。
弾幕を作っていたのですが、行き詰ってしまったので質問させて頂きました。
ボスから10個の弾がバラ撒かれ、100カウントかけて停止し、その60カウント後に、10個の弾のそれぞれが自分以外の弾を直線で結ぶように弾が展開される弾幕を作成しています。
ですが私の力が及ばず、実行結果は何故か画面の左上に変な風に弾が伸びてしまい、また、線分はどうにか描けるのですが、直線に描くことが出来ません。
void makeBullet()は、二つの座標を渡したら、その座標を結ぶ線分状に弾を配置する関数、
double getRand_5(double, double)は、渡された2値間のランダムな数を返す関数、
double shotatan3(double, double, double, double)は、渡された2つの座標の成す角度を返す関数です。
ご指導ご鞭撻の程、宜しくお願い致します。
void makeBullet()定義
弾幕を作っていたのですが、行き詰ってしまったので質問させて頂きました。
ボスから10個の弾がバラ撒かれ、100カウントかけて停止し、その60カウント後に、10個の弾のそれぞれが自分以外の弾を直線で結ぶように弾が展開される弾幕を作成しています。
ですが私の力が及ばず、実行結果は何故か画面の左上に変な風に弾が伸びてしまい、また、線分はどうにか描けるのですが、直線に描くことが出来ません。
void makeBullet()は、二つの座標を渡したら、その座標を結ぶ線分状に弾を配置する関数、
double getRand_5(double, double)は、渡された2値間のランダムな数を返す関数、
double shotatan3(double, double, double, double)は、渡された2つの座標の成す角度を返す関数です。
ご指導ご鞭撻の程、宜しくお願い致します。
void hosizora(){
#define HOSIZORA 1000
#define STOPCOUNT 100 //弾が静止するまでのカウント
int l, k, i, s, h, m, t=boss_shot.cnt%HOSIZORA;//t=0~999
int t2=boss_shot.cnt;
static double spd[10];
static double distance[10];
static double x[10], y[10];
static int f;
static double box1[10][10];
static double box2[10][10];
void makeBullet(double x1, double y1, double x2, double y2, double angle, int divide, int knd, int col, int flag, double spd, int state, int eff, int eff_detail, int cnt, int till);//二つの座標を渡したら、その座標を結ぶ線分状に弾を配置する関数
if(t2==0){
f=0;
for(i=0;i<10;i++){
spd[i] = getRand_5(4,10);
distance[i] = getRand_5(500,900);
}
}
if(t2==100){
for(i=0;i<10;i++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].angle = rang(PI);
boss_shot.bullet[k].spd = distance[i]/STOPCOUNT/2;
boss_shot.bullet[k].knd = 4;
boss_shot.bullet[k].col = 0;
boss_shot.bullet[k].state = 0;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].eff_detail = 1;
}
}
}
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet[i].flag>0){
if(boss_shot.bullet[i].state == 0){
if(boss_shot.bullet[i].cnt<STOPCOUNT){
boss_shot.bullet[i].spd -= boss_shot.bullet[i].spd/(STOPCOUNT-boss_shot.bullet[i].cnt);
}else if(boss_shot.bullet[i].cnt>=STOPCOUNT){
x[f] = boss_shot.bullet[i].x;//fには0~9まで順番に入る
y[f] = boss_shot.bullet[i].y;
boss_shot.bullet[i].cnt=0;
boss_shot.bullet[i].state = 1;
f<9?f++:f=0;
}
}
if(boss_shot.bullet[i].state == 1){
if(boss_shot.bullet[i].cnt==30){
for(h=0;h<9;h++){
for(m=h+1;m<10;m++){
box2[h][m] = shotatan3(x[h], y[h], x[m], y[m]);//二次元配列box2に、それぞれの要素間の角度を格納
}
}
boss_shot.bullet[i].cnt=0;
boss_shot.bullet[i].state=2;
}
}
if(boss_shot.bullet[i].state==2){
if(boss_shot.bullet[i].cnt==30){
for(h=0;h<9;h++){
for(m=h+1;m<10;m++){
makeBullet(x[h], y[h], x[m], y[m], box2[h][m], 40, 2, GetRand(9), 1, 0, 10, 1, 0, 0, 60);
}
}
}
}
}
}
}
void makeBullet(double x1, double y1, double x2, double y2, double angle, int divide, int knd, int col, int flag, double spd, int state, int eff, int eff_detail, int cnt, int till){
//二つの座標を渡したら、その座標を結ぶ線分状に弾を配置する関数
int i,k;
for(i=0;i<divide+1;i++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].x = x1+(x2-x1)/divide*i;
boss_shot.bullet[k].y = (x1+(x2-x1)/divide*i)*tan(angle);
boss_shot.bullet[k].knd = knd;
boss_shot.bullet[k].col = col;
boss_shot.bullet[k].flag = flag;
boss_shot.bullet[k].angle = angle;
boss_shot.bullet[k].spd = spd;
boss_shot.bullet[k].state = state;
boss_shot.bullet[k].eff = eff;
boss_shot.bullet[k].eff_detail = eff_detail;
boss_shot.bullet[k].cnt = cnt;
boss_shot.bullet[k].till = till;
}
}
}