pyxen.input.mouse

Access mouse position, movement, and buttons.

mouse = pyxen.input.mouse

Properties

PropertyTypeDescription
presentboolPlatform supports mouse
posVector2Current mouse position
deltaVector2Movement since last frame

Buttons

  • mouse.left
  • mouse.right
  • mouse.middle

Each is a Button object:

PropertyTypeDescription
downboolTrue while held
pressedboolTrue on the frame the button was pressed
releasedboolTrue on the frame the button was released
valuefloatAnalog value (usually 1.0 or 0.0)
framesintFrames held; 0 on the pressed frame
start_posVector2Cursor position when this button was pressed
if mouse.left.pressed:
    print("Clicked!")

start_pos is captured at the press and held for the life of the press, so you can measure a drag — the mouse analogue of touch.start_pos.


Example: Dragging

if mouse.left.down:
    drag = mouse.pos - mouse.left.start_pos   # vector from press to now
    player.x = mouse.pos.x
    player.y = mouse.pos.y

Notes

  • All properties are read-only
  • delta resets every frame
  • Coordinates are in world/screen space depending on your engine mode


Mini samples

Open from Samples & Tutorials inside Pyxen:

  • input.mouse.pos — Sprite follows the cursor.
  • input.mouse.left.pressed — Spawn a colored dot on every click.