ページ 11

ボスのショットについてです

Posted: 2010年4月17日(土) 02:47
by 胡椒
ボスが二つの大きな弾を撃って、その二つの弾の中心から、また弾を出したいのですが上手くいきません。

void boss_shot_bulletH001(){
#define TM000 120
int i,k,n,t=boss_shot.cnt%TM000,t2=boss_shot.cnt;
int x[2][1],y[2][1];
if(t2==5){
for(i=0;i<2;i++){;
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 4;
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].knd = 0;
boss_shot.bullet[k].angle = (5+2*i)*PI/4;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 1.5;
se_flag[0]=1;
}
}
}
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet.flag>0 && t2==105){
boss_shot.bullet.spd=0;
x[0]=boss_shot.bullet.x;
y[0]=boss_shot.bullet.y;
}
}
if(t2>220 && t>60 && t%5==0){
for(n=0;n<2;n++){
for(i=0;i<30;i++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 1;
boss_shot.bullet[k].x = x[n][0];
boss_shot.bullet[k].y = y[n][0];
boss_shot.bullet[k].knd = 1;
boss_shot.bullet[k].angle = bossatan2()+PI2/30*i;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 5;
se_flag[0]=1;
}
}
}
}
}

としたのですが、どこが悪いのでしょうか?

Re:ボスのショットについてです

Posted: 2010年4月17日(土) 07:30
by あ~る
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet.flag>0 && t2==105){
boss_shot.bullet.spd=0;
x[0]=boss_shot.bullet.x;
y[0]=boss_shot.bullet.y;
}
}

この部分ですね
iの番号は何番かはわからないのに

x[0]

のように使ってるので、例えば、

x[100][0]=boss_shot.bullet[100].x;

みたいな事になり、正しく座標がセット出来ていないんだと思います

Re:ボスのショットについてです

Posted: 2010年4月17日(土) 13:54
by 胡椒
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet.flag>0 && t2==105){
boss_shot.bullet.spd=0;
x[0]=boss_shot.bullet.x;
y[0]=boss_shot.bullet.y;
}
}

for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet.flag>0 && t2==105){
boss_shot.bullet.spd=0;
for(i=0;i<2;i++){
x[0]=boss_shot.bullet.x;
y[i][0]=boss_shot.bullet[i].y;
}
}
}

としてみたり

if(t2==5){
for(i=0;i<2;i++){;
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 4;
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].knd = 0;
boss_shot.bullet[k].angle = (5+2*i)*PI/4;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 1.5;
se_flag[0]=1;
}
}
}
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet[i].flag>0 && t2==105){
boss_shot.bullet[i].spd=0;
x[i][0]=boss_shot.bullet[i].x;
y[i][0]=boss_shot.bullet[i].y;
}
}



if(t2==5){
for(i=0;i<2;i++){;
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 4;
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].knd = 0;
boss_shot.bullet[k].angle = (5+2*i)*PI/4;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 1.5;
se_flag[0]=1;
x[i][0]=boss_shot.bullet[i].x;
y[i][0]=boss_shot.bullet[i].y;
}
}
}
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet[i].flag>0 && t2==105){
boss_shot.bullet[i].spd=0;
}
}

としたりしてみたんですがうまくいきません・・・
あ~るさんの言っている意味は分かるのですが、解決策が思い浮かびません。
どういう風にすればよいのでしょうか?

Re:ボスのショットについてです

Posted: 2010年4月17日(土) 15:45
by あ~る
void boss_shot_bulletH001(){
#define TM001 300
int i,k,n,j,t=boss_shot.cnt%TM001,t2=boss_shot.cnt;
if(t2==5){
for(i=0;i<2;i++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 4;
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].knd = 0;
boss_shot.bullet[k].angle = (5+2*i)*PI/4;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 1.5;
se_flag[0]=1;
}
}
}
for(i=0;i<BOSS_BULLET_MAX;i++){
if(boss_shot.bullet.flag>0){
boss_shot.bullet.spd=0;
if(t2>220 && t>60 && t%5==0){
for(n=0;n<2;n++){
for(j=0;j<30;j++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 1;
boss_shot.bullet[k].x = boss_shot.bullet.x;
boss_shot.bullet[k].y = boss_shot.bullet.y;
boss_shot.bullet[k].knd = 1;
boss_shot.bullet[k].angle = bossatan2()+PI2/30*j;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 5;
se_flag[0]=1;
}
}
}
}
}
}
}

こんな感じでどうでしょうか?
携帯からなんでところどころミスってるかもしれませんが…(-.-;)

Re:ボスのショットについてです

Posted: 2010年4月17日(土) 20:06
by 胡椒
ありがとうございます!
あ~るさんのをヒントに

void boss_shot_bulletH001(){
#define TM001 120
int i,k,x,j,t=boss_shot.cnt%TM002,t2=boss_shot.cnt;
if(t2==5){
for(i=0;i<2;i++){
if((k=search_boss_shot())!=-1){
boss_shot.bullet[k].col = 4;
boss_shot.bullet[k].x = boss.x;
boss_shot.bullet[k].y = boss.y;
boss_shot.bullet[k].knd = 0;
boss_shot.bullet[k].angle = (3+2*i)*PI/4;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 3;
se_flag[0]=1;
}
}
}
for(i=0;i<2;i++){
if(boss_shot.bullet.flag>0 && t2>105){
boss_shot.bullet.spd=0;}
if(t2>240 && t>60 && t%5==0){
for(j=0;j<30;j++){
if((k=search_boss_shot())!=-1){ x=j%9;
boss_shot.bullet[k].col = x;
boss_shot.bullet[k].x = boss_shot.bullet.x;
boss_shot.bullet[k].y = boss_shot.bullet.y;
boss_shot.bullet[k].knd = 8;
boss_shot.bullet[k].angle = bossatan3(i,ch.x,ch.y)+PI2/30*j;
boss_shot.bullet[k].flag = 1;
boss_shot.bullet[k].cnt = 0;
boss_shot.bullet[k].spd = 5;
se_flag[0]=1;
}
}
}
}
}

でできました