ソースを少し変えてみたのですが左にも右にも、ジャンプもできません。どうすればいいでしょうか。
// ジャンプ
#include "DxLib.h"
int PlayerX , PlayerY ;
int JumpPower ;
int PlayerGraph ;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ChangeWindowMode(TRUE);
if (DxLib_Init() == -1) return -1;
char Key[256];
SetGraphMode( 640 , 480 , 16 ) ;
// 描画先画面を裏画面にセット
SetDrawScreen( DX_SCREEN_BACK ) ;
// グラフィックのロード
PlayerGraph = LoadGraph( "Player.bmp" ) ;
// キャラクターの初期データをセット
PlayerX = 0 ;
PlayerY = 0 ;
JumpPower = 0 ;
// ループ
while( ProcessMessage() == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 )
{
if (Key[KEY_INPUT_A]== 1) PlayerY -= 3; // 上を押していたら上に進む
if (Key[KEY_INPUT_B]== 1) PlayerY += 3 ; // 下を押していたら下に進む
if (Key[KEY_INPUT_C]== 1) PlayerX += 3 ; // 右を押していたら右に進む
if (Key[KEY_INPUT_D]== 1) PlayerX -= 3 ; // 左を押していたら左に進む
// 落下処理
PlayerY -= JumpPower ;
// 落下加速度を加える
JumpPower -= 1 ;
// もし地面についていたら止まる
if( PlayerY > 300 )
{
PlayerY = 300 ;
JumpPower = 0 ;
}
// ジャンプボタンを押していて、地面についていたらジャンプ
if ((Key[KEY_INPUT_A]==1) && PlayerY == 300 ) JumpPower = 20 ;
// 画面を初期化する
ClearDrawScreen() ;
// プレイヤーを描画する
DrawGraph( PlayerX , PlayerY , PlayerGraph , TRUE ) ;
// 裏画面の内容を表画面に反映させる
ScreenFlip() ;
}
DxLib_End() ; // DXライブラリ使用の終了処理
return 0 ; // ソフトの終了
}