pyxen.input.mouse
Access mouse position, movement, and buttons.
mouse = pyxen.input.mouse
Properties
| Property | Type | Description |
|---|---|---|
present | bool | Platform supports mouse |
pos | Vector2 | Current mouse position |
delta | Vector2 | Movement since last frame |
Buttons
mouse.leftmouse.rightmouse.middle
Each is a Button object:
| Property | Type | Description |
|---|---|---|
down | bool | True while held |
pressed | bool | True on the frame the button was pressed |
released | bool | True on the frame the button was released |
value | float | Analog value (usually 1.0 or 0.0) |
frames | int | Frames held; 0 on the pressed frame |
start_pos | Vector2 | Cursor 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
deltaresets 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.