ブロックゲームのキーを押したら移動するという簡単な処理を書いているのですが、
いきなり詰まってしまって何かアドバイスを頂けたらと思います。
キーに関するクラス
#ifndef _CKEY_H_
#define _CKEY_H_
class CKey {
public:
CKey();
int GetHitKeyStateAll_2();
int GetInputKey(int KeyCode);
private:
int InputKey[256];
};
#endif
#include "DxLib.h"
#include "CKey.h"
// コンストラクタ
CKey::CKey() {
return ;
}
// キーが押されているか判断する
int CKey::GetHitKeyStateAll_2() {
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll(GetHitKeyStateAll_Key);
for (int i = 0; i < 256; i++) {
if (GetHitKeyStateAll_Key[i] == 1) this->InputKey[i]++;
else this->InputKey[i] = 0;
}
return 0;
}
// 指定されたキーコードの入力状態を返す
int CKey::GetInputKey(int KeyCode) {
return this->InputKey[KeyCode];
}
#ifndef _CBLOCK_H_
#define _CBLOCK_H_
class CBlock {
public:
CBlock();
void Block_Move();
}
#endif
#include "DxLib.h"
#include "CBlock.h"
#include "CKey.h"
CBlock::CBlock() {
return ;
}
void CBlock::Block_Move() {
if (CKey::GetInputKey(KEY_INPUT_UP) != 0)
return ;
}
CBlock::Block_Move関数内の
上キーを押された状態を取得する場合にはどのようにコードを記述するのが良い方法なのでしょうか
開発環境はVC++ 2010です
よろしくお願いします。