私はプロジェクト用のゲームエンジンを作成しています。入力用のものとSDL用のものを使用しています。C++/SDLどのように配列を上書きするか?
私はこのようなものがあります:
class CInput
{
public:
CInput();
Rect MousePosition = Rect(0, 0);
Rect MouseDeltaPosition = Rect(0, 0);
bool GetMouseButton(int button);
bool Process();
private:
bool _mouseButtons[5];
};
bool CInput::GetMouseButton(int button)
{
return _mouseButtons[button - 1];
}
RECT構造体は次のようにされています
struct Rect
{
int x, y;
Rect(int x, int y) : x(x), y(y) {};
};
私は本当によく何のために使用されるマウスボタンや動きをログに記録していますが、それはそうですが私はマウスの位置を設定する/ mousedeltapositionそれは_mouseButtons配列に "オーバーフロー"ですか?誰もボタンを押していない場合であってもテスト中
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_MOUSEMOTION:
MousePosition = Rect(event.motion.x, event.motion.y);
MouseDeltaPosition = Rect(event.motion.xrel, event.motion.yrel);
break;
case SDL_MOUSEBUTTONDOWN:
_mouseButtons[event.button.button - 1] = true;
break;
case SDL_MOUSEBUTTONUP:
_mouseButtons[event.button.button - 1] = false;
break;
case SDL_QUIT:
return 0;
}
}
、_mouseButtonアレイは255で満たされ得ることができます:
は、ここに私のインプットキャプチャです。
EDITは---
これは、単に行うからである。Input.GetMouseButton(0)マウスがある位置
にあるときに255を返し !私はこの問題を絞り込んだ.DeltaMousePosition.yが負の場合、マウスがウィンドウに対して上に動いているように見える!問題の可能性があります
変数がconstであることをコンパイラに嘘をつきましたので、おそらく_があふれています。 – tkausl
[mcve]で編集します。 – genpfault
これは最小ですし、問題のために完了です... –