Code Monkey home page Code Monkey logo

Comments (7)

dapetcu21 avatar dapetcu21 commented on June 11, 2024 2

I think we can close this, as it’s been implemented for all platforms in #57 and #60 (minus clipping for HTML5, but as far as I know that’s not possible).

from defos.

subsoap avatar subsoap commented on June 11, 2024

Locking cursor to center of the window, used in FPS shooters where you want the user to be able to continuously turn around with the mouse. mouse dx and mouse dy are used to get rotation. Generally you want to show a graphic which is centered in the screen and hide the mouse cursor. If you don't hide the mouse cursor as you turn around you'll still see the mouse dx/dy distances from center which is weird.

is_cursor_locked
lock_cursor
unlock_cursor

Clips the cursor to the borders of the current window so that it cannot exit the window bounds. Useful in games like Diablo where you might want to play in window mode with lots of fast clicking and not accidentally click outside of the game window.

is_cursor_clipped
clip_cursor
unclip_cursor

Generally if playing in window mode if the user presses ESC you want to open a pause overlay menu of some kind and unclip the cursor so that it can leave the window bounds.

For FPS game you want similar behavior where pressing ESC displays the normal cursor again which is allowed to move around the window freely while the overlay is visible..

from defos.

rgrams avatar rgrams commented on June 11, 2024

The way d954mas's Lock extension works is it just sets the mouse position back to some preset position every time you call the function and reports dx and dy. So all you really need is a set_mouse_position function. You can get dx and dy from input events normally, and DefOS already has the show/hide cursor functions.

"Capture"ing the mouse to a window should be done with this I think? (no, I was wrong)

from defos.

subsoap avatar subsoap commented on June 11, 2024

@rgrams Should test making a first person shooter type camera with Rendercam. Hide mouse cursor, always set mouse x,y to center of screen, use mouse dx/dy to rotate fps camera.

from defos.

rgrams avatar rgrams commented on June 11, 2024

@subsoap I have. It was pretty darn easy. I used d954mas's Lock extension from his Save Shelter game for the native extension part. (it's Windows & HTML only) If DefOS gets a 'set mouse position' function then I would use that instead.

from defos.

chaosddp avatar chaosddp commented on June 11, 2024

Done for Windows at #57 with clipping

from defos.

subsoap avatar subsoap commented on June 11, 2024

I'll test in next few days unless someone else does before.

from defos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.