mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Correções em Mouse
This commit is contained in:
parent
796bceb034
commit
ac61b48076
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
struct IMouseState {
|
struct IMouseState {
|
||||||
ButtonState LeftButton{ 0 };
|
ButtonState LeftButton{ ButtonState::Released };
|
||||||
ButtonState RightButton{ 0 };
|
ButtonState RightButton{ ButtonState::Released };
|
||||||
ButtonState MiddleButton{ 0 };
|
ButtonState MiddleButton{ ButtonState::Released };
|
||||||
ButtonState XButton1{ 0 };
|
ButtonState XButton1{ ButtonState::Released };
|
||||||
ButtonState XButton2{ 0 };
|
ButtonState XButton2{ ButtonState::Released };
|
||||||
int X{ 0 };
|
int X{ 0 };
|
||||||
int Y{ 0 };
|
int Y{ 0 };
|
||||||
int ScroolWheelValue{ 0 };
|
int ScroolWheelValue{ 0 };
|
||||||
|
@ -10,14 +10,14 @@ namespace xna {
|
|||||||
|
|
||||||
constexpr MouseState(DirectX::Mouse::State const& dxMouseState) {
|
constexpr MouseState(DirectX::Mouse::State const& dxMouseState) {
|
||||||
LeftButton = static_cast<ButtonState>(dxMouseState.leftButton);
|
LeftButton = static_cast<ButtonState>(dxMouseState.leftButton);
|
||||||
RightButton = static_cast<ButtonState>(dxMouseState.leftButton);
|
RightButton = static_cast<ButtonState>(dxMouseState.rightButton);
|
||||||
MiddleButton = static_cast<ButtonState>(dxMouseState.leftButton);
|
MiddleButton = static_cast<ButtonState>(dxMouseState.middleButton);
|
||||||
XButton1 = static_cast<ButtonState>(dxMouseState.leftButton);
|
XButton1 = static_cast<ButtonState>(dxMouseState.xButton1);
|
||||||
XButton2 = static_cast<ButtonState>(dxMouseState.leftButton);
|
XButton2 = static_cast<ButtonState>(dxMouseState.xButton2);
|
||||||
X = dxMouseState.x;
|
X = dxMouseState.x;
|
||||||
Y = dxMouseState.y;
|
Y = dxMouseState.y;
|
||||||
ScroolWheelValue = dxMouseState.scrollWheelValue;
|
ScroolWheelValue = dxMouseState.scrollWheelValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mouse : public IMouse {
|
struct Mouse : public IMouse {
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
void Update(GameTime const& gameTime) override {
|
void Update(GameTime const& gameTime) override {
|
||||||
|
|
||||||
const auto state = Keyboard::GetState();
|
const auto state = Keyboard::GetState();
|
||||||
|
|
||||||
if (state.IsKeyDown(Keys::Right)) {
|
if (state.IsKeyDown(Keys::Right)) {
|
||||||
position.X += 1 * gameTime.ElapsedGameTime.TotalMilliseconds();
|
position.X += 1 * gameTime.ElapsedGameTime.TotalMilliseconds();
|
||||||
@ -49,12 +49,13 @@ public:
|
|||||||
}
|
}
|
||||||
if (state.IsKeyDown(Keys::Down)) {
|
if (state.IsKeyDown(Keys::Down)) {
|
||||||
position.Y += 1 * gameTime.ElapsedGameTime.TotalMilliseconds();
|
position.Y += 1 * gameTime.ElapsedGameTime.TotalMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
oldState = currentState;
|
oldState = currentState;
|
||||||
const auto currentState = Mouse::GetState();
|
currentState = Mouse::GetState();
|
||||||
|
|
||||||
if (currentState.LeftButton == ButtonState::Pressed && oldState.LeftButton == ButtonState::Released) {
|
if (currentState.LeftButton == ButtonState::Pressed && oldState.LeftButton == ButtonState::Released) {
|
||||||
points.push_back(Vector2(currentState.X, currentState.Y));
|
points.push_back(Vector2(currentState.X, currentState.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +82,8 @@ private:
|
|||||||
PTexture2D texture = nullptr;
|
PTexture2D texture = nullptr;
|
||||||
Vector2 position{};
|
Vector2 position{};
|
||||||
std::vector<Vector2> points;
|
std::vector<Vector2> points;
|
||||||
MouseState currentState;
|
MouseState currentState{};
|
||||||
MouseState oldState;
|
MouseState oldState{};
|
||||||
float vel = 1;
|
float vel = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user