shooter/engine/Mouse.h

37 lines
835 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>
2021-10-31 11:39:08 +03:00
2021-10-28 16:58:02 +03:00
#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-31 11:39:08 +03:00
// returns true if this _button is _pressed
static bool isButtonPressed(sf::Mouse::Button button);
// returns true if this _button is tapped and 1/5 sec passed (_button bouncing problem solved)
bool isButtonTapped(sf::Mouse::Button button);
[[nodiscard]] Vec2D getMousePosition() const;
2021-10-31 11:39:08 +03:00
[[nodiscard]] Vec2D getMouseDisplacement() const;
2021-10-31 11:39:08 +03:00
void setMouseInCenter() const;
};
#endif //SHOOTER_MOUSE_H