The global "mouse" is non-nil when a working mouse is attached to the computer.
The x and y axes of the mouse represent the system cursor location.
The origin of the cursor (0, 0) is the center of the game window, not its top-left corner.
Moving the mouse cursor up increases its y-axis value and moving it right increases its x-axis value.
Remember that the cursor position is measured in display resolution pixels.
If the cursor is moved to the left end of the window, it would have an x-axis value of negative half the resolution width even if the window is resized.
Figure 1: Mouse cursor positions in an 800 by 600 window
Unlike the x and y axes, the z-axis of the mouse does not have an absolute position.
Instead, you will be notified of its relative change in notches through the "on_wheelmove" event.
Model name of the mouse device. This is a read-only string value
Absolute x-position of the mouse cursor in pixels. This is a number value
Absolute y-position of the mouse cursor in pixels. This is a number value
- hide_cursor ( )
Makes the cursor invisible and traps it within the game window
- is_down ( button )
Returns true if the supplied button is currently pressed
- is_up ( button )
Returns true if the supplied button is currently released
- set_cursor_pos ( x, y )
Changes the position of the cursor
- show_cursor ( )
Makes the cursor visible
- on_move ( mouse, dx, dy )
Called continually while the the mouse is being moved.
dx and dy show the relative change in the cursor's position
- on_press ( mouse, button )
Called when a mouse button is pressed
- on_release ( mouse, button )
Called when a mouse button is released
- on_wheelmove ( mouse, dz )
Called continually while the mouse wheel is being scrolled.
dz shows the relative change in notches