ブロック崩しのステージを2-3面まで増やしました。
ステージ2ではバーの移動範囲をベルトコンベアのようにしてあるのと
ブロックを一定の条件で動くようにしました。
2-3面にボスを設定したのですがボスの攻撃で左右にモノを投げるというような攻撃をするようにしています。
投げたモノが壁に反射するようにしたいのですがうまく反射してくれません。
最初は構造体shot[0](左側)とshot[1](右側)で反射するshot[].xの位置、x軸方向の速さshot[].dxが異なるので
if(shot[0].flag == TRUE){
shot[0].x += shot[0].dx;
shot[0].dy +=accel;
shot[0].y +=shot[0].dy;
if(shot[0].x <30)
shot[0].dx *= -1;
if(shot[0].y >450){
shot[0].dx = -1;shot[0].dy = 1;
shot[0].flag = FALSE;
shot[0].x = 0;shot[0].y = 0;
}
}
if(shot[1].flag == TRUE){
shot[1].x += shot[1].dx;
shot[1].dy +=accel;
shot[1].y +=shot[1].dy;
if(shot[1].x >400)
shot[1].dx *=-1;
if(shot[1].y>450){
shot[1].dx = 1;shot[1].dy = 1;
shot[1].flag = FALSE;
shot[1].x = 0;shot[1].y = 0;
}
}
for(l = 0;l<2;l++){
if(shot[l].flag == TRUE){
shot[l].cnt++;
shot[l].x += shot[l].dx;
shot[l].dy += accel;
shot[l].y += shot[l].dy;
if(shot[0].x <30)
shot[0].dx *=-1;
if(shot[1].x >400)
shot[1].dx *=-1;
if(shot[l].y >450){
shot[l].dx = -1*pow(-1.0,l);shot[l].dy = 1;
shot[l].flag = FALSE;
shot[l].x = 0;shot[l].y = 0;
}
}
}
また、たまに左右に投げるモノが2つとも同じ方向(右側)に投げます。
正直、どうすればよいのかわからなかったので質問させていただきました。
データは下記のサイトにアップしてあります。パスワードは「YT2013」です。
http://www1.axfc.net/uploader/so/2848394
よろしくお願いします。