[Added] The ability to fire bullets to the player

This commit is contained in:
Ninjaws
2024-12-13 22:04:33 +01:00
parent 88e0b7cb05
commit 55792bb954
7 changed files with 266 additions and 9 deletions
+12
View File
@@ -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;
}
}
};