弾が重なってしまううえ、移動しながら弾を撃つと撃てなくなってしまいます。どうすればいいんでしょうか?
#include "DxLib.h"
int Key[256];
int gpUpdateKey(){
char tmpKey[256];
GetHitKeyStateAll( tmpKey );
for( int i=0; i<256; i++ ){
if( tmpKey[i] != 0 ){
Key[i]++;
} else {
Key[i] = 0; // 0にする
}
}
return 0;
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK );
int playerx=100,playery=300;
int Handle=LoadGraph("画像/自機.png");
int Bullet=LoadGraph("画像/弾.png");
int Bulletx=0,Bullety=0;
int j=0;
int Bflag[6];
for(j=0;j<6;j++){
Bflag[j]=0;
}
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && gpUpdateKey()==0 ){
if(CheckHitKey(KEY_INPUT_RIGHT)){
playerx+=3;
}
if(CheckHitKey(KEY_INPUT_LEFT)){
playerx-=3;
}
if(CheckHitKey(KEY_INPUT_UP)){
playery-=3;
}
if(CheckHitKey(KEY_INPUT_DOWN)){
playery+=3;
}
if(Key[KEY_INPUT_SPACE]>=1){
for(j=0;j<6;j++){
if(Bflag[j]==0){
Bulletx=playerx;
Bullety=playery;
Bflag[j]=1;
break;
}
}
}
for(j=0;j<6;j++){
if(Bflag[j]==1){
Bulletx+=5;
Bullety=playery;
}
DrawRotaGraph(Bulletx,Bullety,1.0,0.0,Bullet,true);
if(Bulletx==540){
Bflag[j]=0;
}
}
DrawRotaGraph(playerx,playery,1.0,0.0,Handle,true);
}
DxLib_End();
return 0;
}