ゲームのバグについて
Posted: 2009年3月16日(月) 16:40
ゲームを作っていて実行中に右から落ちると左にいきなり出てくるのですがどうしてでしょうか?
#include "DxLib.h"
int Key[256];
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
static int count=0;
typedef struct{
int X,Y;
}kyara1P;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
// 透過色を変更 白を透過
SetTransColor( 255 , 255 ,255 ) ;
int White = GetColor( 255 , 255 , 255 ) ; // 白の色を取得
kyara1P Player1P;
Player1P.X=62;
Player1P.Y=350;
int haikei= LoadGraph("green.bmp");
int kyaraimage[10];
kyaraimage[0]= LoadGraph("picture[0].bmp");
kyaraimage[1]= LoadGraph("picture[1].bmp");
kyaraimage[2]= LoadGraph("picture[2].bmp");
kyaraimage[3]= LoadGraph("picture[3].bmp");
kyaraimage[4]= LoadGraph("picture[4].bmp");
kyaraimage[5]= LoadGraph("picture[5].bmp");
kyaraimage[6]= LoadGraph("picture[6].bmp");
kyaraimage[7]= LoadGraph("picture[7].bmp");
kyaraimage[8]= LoadGraph("picture[8].bmp");
kyaraimage[9]= LoadGraph("picture[0].bmp");
int muki=1;
int jyuryoku=0;
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
Player1P.Y+=jyuryoku;
jyuryoku=2;
if(Player1P.X>=16 && Player1P.X<=564 &&Player1P.Y > 350 && Player1P.Y<354 )
{
Player1P.Y = 350 ;
jyuryoku = 0 ;
}
if(Player1P.X>=10 && Player1P.X<=16 && Player1P.Y>380 && Player1P.Y<400)
{
jyuryoku = 0;
muki=7;
}
if(Player1P.X>=564 && Player1P.X<=568 && Player1P.Y>380 && Player1P.Y<400)
{
jyuryoku = 0;
muki=8;
}
if( Player1P.Y==480){Player1P.X=62; Player1P.Y=350; muki=1;}
if( Key[ KEY_INPUT_LEFT]==1 || ( Key[ KEY_INPUT_LEFT]>10) && count%2){muki=2;Player1P.X-=2;}
if( Key[ KEY_INPUT_RIGHT]==1|| ( Key[ KEY_INPUT_RIGHT]>10) && count%2){muki=1;Player1P.X+=2;}
if( Key[ KEY_INPUT_DOWN]==1 || ( Key[ KEY_INPUT_DOWN]>10) && count%2 && Player1P.Y<=348) Player1P.Y+=2;
if( Key[ KEY_INPUT_Z] == 1 )
{
if(muki==1)muki=3;
if(muki==2)muki=4;
}
if( Key[ KEY_INPUT_A] == 1 && Player1P.Y==350){
if(muki==1)muki=5;
if(muki==2)muki=6;
Player1P.Y-=100;
}
if(Player1P.X>12 && Player1P.Y > 400)
{Player1P.X=12;}
count++;
if(Player1P.X<0)Player1P.X=0;
if(Player1P.X>640-71)Player1P.X=640-71;
DrawGraph(0,0,haikei,FALSE);
DrawFormatString( 0, 0, White, "Player1P.Xは%d\n",Player1P.X ) ;
DrawFormatString( 0, 50, White, "Player1P.Yは%d\n",Player1P.Y) ;
DrawGraph(Player1P.X,Player1P.Y,kyaraimage[muki],TRUE);
ScreenFlip();
}
DxLib_End();
return 0;
}