左キーを押すと、ちょこっと左にカクンってなるのですが、すぐ元の位置に戻ってしまいます。
#include "DxLib.h"
struct chara {
int chara_x;
int chara_y;
int chara_image;
}test;
int image[12];
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;
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
//プログラミング開始
test.chara_x =300;
test.chara_y =140;
LoadDivGraph("test.png", 12 , 3 , 4 , 32 , 32 , image ) ;
if(Key[ KEY_INPUT_LEFT ] == 1 )
test.chara_x++ ;
test.chara_image = image[5] ;
DrawGraph( test.chara_x , test.chara_y , test.chara_image , TRUE );
//プログラミング終了
ScreenFlip();
}
DxLib_End();
return 0;
}
一応エラーはでないで出来ました。
どうすれば左に移動してくれるのでしょうか?
