Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggested changes for mouse position how to from discord #145

Open
wants to merge 1 commit into
base: 1.11
Choose a base branch
from

Conversation

BMaxV
Copy link

@BMaxV BMaxV commented Feb 26, 2024

https://discord.com/channels/524691714909274162/1057767450843824198/1211462257725145150

12:54 AM]Simulan:
                # get mouse data
                mouse_watch = base.mouseWatcherNode
                if mouse_watch.has_mouse():
                    pointer = base.win.get_pointer(0)
                    mouseX = pointer.get_x()
                    mouseY = pointer.get_y()

...is how I've been doing it for FPS
[12:57 AM]rdb: Er, you're mixing interfaces
[12:58 AM]rdb: Instead of checking has_mouse(), check pointer.in_window
[12:58 AM]rdb: Your code may occasionally behave erratically in some edge cases
[12:59 AM]Simulan: Hmm okay I'll check it out later
[1:07 AM]Simulan: So I suppose that should be:

                # get mouse data
                pointer = base.win.get_pointer(0)
                if pointer.in_window:
                    mouseX = pointer.get_x()
                    mouseY = pointer.get_y()

y = base.mouseWatcherNode.getMouseY()
pointer = base.win.get_pointer(0)
if pointer.in_window:
mouseX = pointer.get_x()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad indent, needs another space on this line

Let's encourage pointer.x and pointer.y instead

Variable names should be all-lower-caps, so use mouse_x and mouse_y (or just x and y as in the original)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants