[Added] The ability to fire bullets to the player
This commit is contained in:
@@ -57,10 +57,15 @@ public:
|
||||
for (auto button : watchedMouseButtons)
|
||||
{
|
||||
mouseButtonsPressed[button] = false;
|
||||
mouseButtonsDown[button] = false;
|
||||
if (IsMouseButtonPressed(button))
|
||||
{
|
||||
mouseButtonsPressed[button] = true;
|
||||
}
|
||||
if (IsMouseButtonDown(button))
|
||||
{
|
||||
mouseButtonsDown[button] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,22 +83,29 @@ public:
|
||||
return mouseButtonsPressed[button];
|
||||
}
|
||||
|
||||
bool isMouseButtonDown(MouseButton button) {
|
||||
return mouseButtonsDown[button];
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_set<KeyboardKey> watchedKeys;
|
||||
std::unordered_map<KeyboardKey, bool> keysPressed;
|
||||
std::unordered_map<KeyboardKey, bool> keysDown;
|
||||
std::unordered_set<MouseButton> watchedMouseButtons;
|
||||
std::unordered_map<MouseButton, bool> mouseButtonsPressed;
|
||||
std::unordered_map<MouseButton, bool> mouseButtonsDown;
|
||||
|
||||
void setMouseButtonsToWatch(std::vector<MouseButton> mouseButtonsToWatch)
|
||||
{
|
||||
this->watchedMouseButtons.clear();
|
||||
this->mouseButtonsPressed.clear();
|
||||
this->mouseButtonsDown.clear();
|
||||
|
||||
for (int i = 0; i < mouseButtonsToWatch.size(); i++)
|
||||
{
|
||||
this->watchedMouseButtons.insert(mouseButtonsToWatch[i]);
|
||||
this->mouseButtonsPressed[mouseButtonsToWatch[i]] = false;
|
||||
this->mouseButtonsDown[mouseButtonsToWatch[i]] = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user