キーの入力を反転するようなもの

アップローダー代わりに自分( 3D )が書いたコードを乗っけるだけのコミュニティ。
いわばメモ帳。
フォーラム(掲示板)ルール
mixC++のフォーラムルールが基本。
コードを乗っけるたびに(関係したコード以外は)トピックを立てる。

などなど。
閉鎖
Rittai_3D
記事: 525
登録日時: 11年前

キーの入力を反転するようなもの

#1

投稿記事 by Rittai_3D » 9年前

コード:

// 下位4ビットは移動キーに割り当てる。

const Button	BUTTON_UP    = 0x00001;
const Button	BUTTON_LEFT  = 0x00002;
const Button	BUTTON_DOWN  = 0x00004;
const Button	BUTTON_RIGHT = 0x00008;

const Button	BUTTON_SHOT = 0x00010;
const Button	BUTTON_BOMB = 0x00020;
const Button	BUTTON_SLOW = 0x00040;

コード:

typedef unsigned int Button;
Button GetTurnedKeyState()
{
	auto dirKey = m_InputState & 0x0f;
	auto tmp = ( dirKey & 0x03 ) << 2;
	auto turnedDirKey = ( dirKey >> 2 ) | tmp;

	return turnedDirKey;
}

コード:

void sampleFunc( bool turn )
{
	if( turn ) {
		auto anotherKey = m_InputState - ( m_InputState & 0x0f );
		m_InputState = GetTurnedKeyState() | anotherKey;
	}
}
BUTTON_~はゲーム内でのキーとして使う。理想の仮想キーコード。
sampleFunc()の anotherKey は方向キー以外のキー入力。
初心者です

閉鎖

“マイ サンプルズ” へ戻る