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

Mouse Input #8

Open
avarsh opened this issue Jul 5, 2019 · 0 comments
Open

Mouse Input #8

avarsh opened this issue Jul 5, 2019 · 0 comments
Labels
input Relating to the input system.

Comments

@avarsh
Copy link
Owner

avarsh commented Jul 5, 2019

To implement mouse input, we need a system for detecting and transmitting mouse events such as mouse position and clicks.

Mouse positioning

Generally, elements such as interface items (e.g. buttons) or game items within the world which may be clickable require mouse position input. A proposed approach is as follows: entities may hold a mouseover component which has as its data the bounds (either in terms of the window, or the game world) which the component wants to "watch". A system then iterates through all mouseover components and checks the mouse position in that tick. It calculates both the absolute position relative to the window and to the center of the world, by converting the position into world coordinates by taking the position of the viewport and adding the position of the mouse relative to the window (adjusting for scaling). The system accordingly invokes a callback if the mouse is inside relevant bounds.

Mouse clicks

Similarly to above, entities may register a mouseclick component to watch for clicks. When a click occurs, all clickable entities are looped over and a callback function is fired.

It is additionally important to consider the z-index of indices so that overlapping entities' actions are not both executed. We may be able to utilise the scene graph for this, or we may let the user develop their own system; for example by adding layers and checking which layers are visible.

@avarsh avarsh added the input Relating to the input system. label Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Relating to the input system.
Projects
None yet
Development

No branches or pull requests

1 participant