コードが汚いですが、どうすればよいでしょうか?
フォーラムルールに記載されていますがcodeタグをご利用下さい。
プログラムコードが格段に読みやすくなります。 be softya(ソフト屋)
#include "DxLib.h"
typedef struct{
int x,y,img;
}ch_t;
struct shot{
int x,y;
int flag;
};
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
char Key[256];
ch_t ch;
int image[20],i,counter=0;
struct shot tama[20];
ch.x=320;
ch.y=320;
if( ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() == -1 ) return -1; //初期化処理
SetDrawScreen( DX_SCREEN_BACK );
//裏画面に設定
LoadDivGraph("char.png",20,4,5,32,32,image);
//弾準備開始
for(i=0;i<20;i++){
tama[i].x=2000;
tama[i].y=2000;
tama[i].flag=0;}
//弾準備終了
while(!ProcessMessage() && !ClearDrawScreen() && !GetHitKeyStateAll( Key ) && !Key[KEY_INPUT_ESCAPE]){
//↑メッセージ処理 ↑画面をクリア ↑キーボード入力状態取得 ↑ESCが押されていない
if(Key[KEY_INPUT_RIGHT]==1)
ch.x++;
if(Key[KEY_INPUT_LEFT]==1)
ch.x--;
if(Key[KEY_INPUT_UP]==1)
ch.y--;
if(Key[KEY_INPUT_DOWN]==1)
ch.y++;
if(counter<5)
counter++;
else if(Key[KEY_INPUT_Z]==1){
for(i=0;i<20;i++){
if(tama[i].flag==0){
tama[i].flag=1;
tama[i].x=ch.x;
tama[i].y=ch.y;
counter=0; break;}}}
for(i=0;i<20;i++){
if(tama[i].flag==1){
tama[i].y-=8;
if(tama[i].y<-32){
tama[i].y=2000;
tama[i].flag=0;}}}
DrawGraph(tama[i].x,tama[i].y,image[1],TRUE);
DrawGraph(ch.x , ch.y , image[1] ,TRUE);
ScreenFlip();//裏画面を表画面に反映
}
DxLib_End();
return 0;
}