feat: players interpolation & add hud.set_allow_pause(...)
This commit is contained in:
+11
-7
@@ -18,8 +18,8 @@ uint Events::currentFrame = 0;
|
||||
int Events::scroll = 0;
|
||||
glm::vec2 Events::delta = {};
|
||||
glm::vec2 Events::cursor = {};
|
||||
bool Events::cursor_drag = false;
|
||||
bool Events::_cursor_locked = false;
|
||||
bool Events::cursorDrag = false;
|
||||
bool Events::cursorLocked = false;
|
||||
std::vector<uint> Events::codepoints;
|
||||
std::vector<keycode> Events::pressedKeys;
|
||||
std::unordered_map<std::string, Binding> Events::bindings;
|
||||
@@ -61,10 +61,10 @@ bool Events::jclicked(int button) {
|
||||
}
|
||||
|
||||
void Events::toggleCursor() {
|
||||
cursor_drag = false;
|
||||
_cursor_locked = !_cursor_locked;
|
||||
cursorDrag = false;
|
||||
cursorLocked = !cursorLocked;
|
||||
Window::setCursorMode(
|
||||
_cursor_locked ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL
|
||||
cursorLocked ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -170,11 +170,11 @@ void Events::setButton(int button, bool b) {
|
||||
}
|
||||
|
||||
void Events::setPosition(float xpos, float ypos) {
|
||||
if (Events::cursor_drag) {
|
||||
if (Events::cursorDrag) {
|
||||
Events::delta.x += xpos - Events::cursor.x;
|
||||
Events::delta.y += ypos - Events::cursor.y;
|
||||
} else {
|
||||
Events::cursor_drag = true;
|
||||
Events::cursorDrag = true;
|
||||
}
|
||||
Events::cursor.x = xpos;
|
||||
Events::cursor.y = ypos;
|
||||
@@ -249,3 +249,7 @@ void Events::enableBindings() {
|
||||
binding.enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Events::isCursorLocked() {
|
||||
return cursorLocked;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ class Events {
|
||||
static bool keys[KEYS_BUFFER_SIZE];
|
||||
static uint frames[KEYS_BUFFER_SIZE];
|
||||
static uint currentFrame;
|
||||
static bool cursor_drag;
|
||||
static bool cursorDrag;
|
||||
static bool cursorLocked;
|
||||
public:
|
||||
static int scroll;
|
||||
static glm::vec2 delta;
|
||||
static glm::vec2 cursor;
|
||||
static bool _cursor_locked;
|
||||
static std::vector<uint> codepoints;
|
||||
static std::vector<keycode> pressedKeys;
|
||||
static std::unordered_map<std::string, Binding> bindings;
|
||||
@@ -65,4 +65,6 @@ public:
|
||||
BindType bindType
|
||||
);
|
||||
static void enableBindings();
|
||||
|
||||
static bool isCursorLocked();
|
||||
};
|
||||
|
||||
@@ -389,7 +389,9 @@ void Window::toggleFullscreen() {
|
||||
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||
|
||||
if (Events::_cursor_locked) Events::toggleCursor();
|
||||
if (Events::isCursorLocked()){
|
||||
Events::toggleCursor();
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
glfwGetWindowPos(window, &posX, &posY);
|
||||
|
||||
Reference in New Issue
Block a user