shooter/engine/Mouse.h

31 lines
823 B
C
Raw Normal View History

//
// Created by Иван Ильин on 19.09.2021.
//
#ifndef SHOOTER_MOUSE_H
#define SHOOTER_MOUSE_H
2021-10-03 08:38:10 +03:00
#include <memory>
2021-10-28 16:58:02 +03:00
#include <utility>
#include "Screen.h"
#include "Vec2D.h"
class Mouse final {
private:
2021-10-28 16:58:02 +03:00
const std::shared_ptr<Screen> _screen;
std::map<sf::Mouse::Button, double> _tappedButtons;
public:
2021-10-28 16:58:02 +03:00
explicit Mouse(std::shared_ptr<Screen> screen) : _screen(std::move(screen)) {};
2021-10-03 07:47:05 +03:00
static bool isButtonPressed(sf::Mouse::Button button); // returns true if this _button is _pressed
bool isButtonTapped(sf::Mouse::Button button); // returns true if this _button is tapped and 1/5 sec passed (_button bouncing problem solved)
[[nodiscard]] Vec2D getMousePosition() const;
[[nodiscard]] Vec2D getMouseDisplacement() const;
void setMouseInCenter() const;
};
#endif //SHOOTER_MOUSE_H