EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.75k stars 136 forks source link

Add function to disable cursor #803

Open Noofbiz opened 9 months ago

Noofbiz commented 9 months ago

For things like First-Person games, the cursor should be locked to the window, so moving too far left or right out of the window doesn't stop the gameplay.

brunoga commented 3 months ago

I assume you are talking about desktop, right? FWIIW, I accomplished this by doing this (I do have a "game" using engo that requires the behavior you describe):

        // Disable cursor.
    if engo.CurrentBackEnd == engo.BackEndGLFW ||
        engo.CurrentBackEnd == engo.BackEndVulkan {
        glfw.GetCurrentContext().SetInputMode(glfw.CursorMode,
            glfw.CursorDisabled)
    } else {
        panic("Backend does not seem to support mouse capture.")
    }

https://github.com/brunoga/robomaster-control/blob/c6764bc8fee10ad3c8fa50899809f175ad0c068a/scenes/robomaster.go#L59