2021-09-19 15:44:31 +03:00
|
|
|
//
|
|
|
|
// 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-09-19 15:44:31 +03:00
|
|
|
#include <SFML/Graphics.hpp>
|
2021-10-12 17:12:47 +03:00
|
|
|
#include "Vec2D.h"
|
2021-09-19 15:44:31 +03:00
|
|
|
|
|
|
|
class Mouse {
|
|
|
|
private:
|
|
|
|
std::shared_ptr<sf::RenderWindow> _window;
|
|
|
|
|
|
|
|
std::map<sf::Mouse::Button, double> _tappedButtons;
|
|
|
|
public:
|
|
|
|
Mouse() = default;
|
|
|
|
|
|
|
|
void setWindow(std::shared_ptr<sf::RenderWindow> window);
|
|
|
|
|
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)
|
2021-09-19 15:44:31 +03:00
|
|
|
|
2021-10-12 17:12:47 +03:00
|
|
|
[[nodiscard]] Vec2D getMousePosition() const;
|
|
|
|
[[nodiscard]] Vec2D getMouseDisplacement() const;
|
2021-09-19 15:44:31 +03:00
|
|
|
void setMouseInCenter() const;
|
|
|
|
void setMouseCursorVisible(bool visible);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SHOOTER_MOUSE_H
|