エラーと他方向分岐?についての質問
Posted: 2010年11月22日(月) 03:10
visualC++ DXライブラリ使用です
今、野球ゲーム作りを目指していて、下のようなプログラムを書きました
#include "../include/GV.h"
void mode_pitch(){
DrawGraph( 0 , 0 , mound_h , TRUE);
LoadGraphScreen( pitch_x , 90 , "../dat/左上.png" , TRUE ) ;
if(pitch_x>290&&pitch_x<330&&pitch==0){
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
pitch_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
pitch_x--;
}
if(pitch_x==290)pitch_x=291;
if(pitch_x==330)pitch_x=329;
}
if(CheckStateKey(KEY_INPUT_RETURN)==1&&(!(CheckStateKey(KEY_INPUT_UP)>1))&&(!(CheckStateKey(KEY_INPUT_DOWN)>1))&&pitch==0){
Sleep(1000);
pitch = 1;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RETURN)==1&&CheckStateKey(KEY_INPUT_UP)>1&&pitch==0){
Sleep(1000);
pitch = 2;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RETURN)==1&&CheckStateKey(KEY_INPUT_DOWN)>1&&pitch==0){
Sleep(1000);
pitch = 3;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RSHIFT)==1&&pitch==0){
pitch = 4;
}else if(ball_y >= 480){
pitch = 0;
}
if(pitch==1){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+10;
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
ball_x=ball_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
ball_x=ball_x--;
}
}else if(pitch==2){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+5;
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
ball_x=ball_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
ball_x=ball_x--;
}
}else if(pitch==3){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+5;
if(ball_y>300){
LoadGraphScreen( ball_x , ball_y+1 , "../dat/影.png" , TRUE ) ;
}
}else if(pitch==4){
mode_run();
mode_def();
}
mode_bat_com();
}
簡単に言うとエンター押すと投球に入り、右シフトで牽制するという感じ(mode_run();mode_def();は牽制のために画面が切り替わって行動する関数って感じです)なのですが実はこの関数、どこかに欠陥があるみたいで、最初から右シフト押すと牽制画面にちゃんといくのですが、一度投球してからだと牽制画面にうまくいきません
どううまくいかないかというとほんの一瞬は牽制の画面が映るのですが、すぐにこの投球画面に戻ってしまう感じです
ですから投げた後の初期化がうまくいってないのではないかと思うんですがどこがいけないのかさっぱりで・・・
あと他方向分岐についてっていうのは
else if(ball_y >= 480){
pitch = 0;
}
のところを
if(ball_y >= 480){
pitch = 0;
}
にしたら今度はほんの一瞬の牽制画面すら映らなくなったんですがなぜでしょうか?
正直else ifっていらなくね?ifでいいじゃん っていうアホなレベルなので・・・
よろしくお願いします
今、野球ゲーム作りを目指していて、下のようなプログラムを書きました
#include "../include/GV.h"
void mode_pitch(){
DrawGraph( 0 , 0 , mound_h , TRUE);
LoadGraphScreen( pitch_x , 90 , "../dat/左上.png" , TRUE ) ;
if(pitch_x>290&&pitch_x<330&&pitch==0){
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
pitch_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
pitch_x--;
}
if(pitch_x==290)pitch_x=291;
if(pitch_x==330)pitch_x=329;
}
if(CheckStateKey(KEY_INPUT_RETURN)==1&&(!(CheckStateKey(KEY_INPUT_UP)>1))&&(!(CheckStateKey(KEY_INPUT_DOWN)>1))&&pitch==0){
Sleep(1000);
pitch = 1;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RETURN)==1&&CheckStateKey(KEY_INPUT_UP)>1&&pitch==0){
Sleep(1000);
pitch = 2;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RETURN)==1&&CheckStateKey(KEY_INPUT_DOWN)>1&&pitch==0){
Sleep(1000);
pitch = 3;
ball_x=pitch_x;
ball_y = 90;
}else if(CheckStateKey(KEY_INPUT_RSHIFT)==1&&pitch==0){
pitch = 4;
}else if(ball_y >= 480){
pitch = 0;
}
if(pitch==1){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+10;
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
ball_x=ball_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
ball_x=ball_x--;
}
}else if(pitch==2){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+5;
if(CheckStateKey(KEY_INPUT_RIGHT)>1){
ball_x=ball_x++;
}
if(CheckStateKey(KEY_INPUT_LEFT)>1){
ball_x=ball_x--;
}
}else if(pitch==3){
DrawGraph( ball_x , ball_y , ball_h , TRUE);
ball_y=ball_y+5;
if(ball_y>300){
LoadGraphScreen( ball_x , ball_y+1 , "../dat/影.png" , TRUE ) ;
}
}else if(pitch==4){
mode_run();
mode_def();
}
mode_bat_com();
}
簡単に言うとエンター押すと投球に入り、右シフトで牽制するという感じ(mode_run();mode_def();は牽制のために画面が切り替わって行動する関数って感じです)なのですが実はこの関数、どこかに欠陥があるみたいで、最初から右シフト押すと牽制画面にちゃんといくのですが、一度投球してからだと牽制画面にうまくいきません
どううまくいかないかというとほんの一瞬は牽制の画面が映るのですが、すぐにこの投球画面に戻ってしまう感じです
ですから投げた後の初期化がうまくいってないのではないかと思うんですがどこがいけないのかさっぱりで・・・
あと他方向分岐についてっていうのは
else if(ball_y >= 480){
pitch = 0;
}
のところを
if(ball_y >= 480){
pitch = 0;
}
にしたら今度はほんの一瞬の牽制画面すら映らなくなったんですがなぜでしょうか?
正直else ifっていらなくね?ifでいいじゃん っていうアホなレベルなので・・・
よろしくお願いします