-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmouse.go
More file actions
45 lines (39 loc) · 999 Bytes
/
mouse.go
File metadata and controls
45 lines (39 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package pigo8
import (
"github.com/hajimehoshi/ebiten/v2"
)
// Note: Mouse button constants are defined in controls.go
// mouseX and mouseY store the current mouse position
var (
mouseX int
mouseY int
mouseWheel struct {
x float64
y float64
}
)
// updateMouseState updates the internal mouse state.
// This should be called once per frame in the game's Update method.
func updateMouseState() {
// Update mouse position
mouseX, mouseY = ebiten.CursorPosition()
// Update mouse wheel values
wheelX, wheelY := ebiten.Wheel()
mouseWheel.x = wheelX
mouseWheel.y = wheelY
}
// GetMouseXY returns the current mouse X and Y coordinates.
// This mimics PICO-8's mouse() function.
//
// Usage:
//
// x, y := GetMouseXY()
//
// Example:
//
// // Get mouse position and draw a circle at that position
// mouseX, mouseY := GetMouseXY()
// Circ(mouseX, mouseY, 4, 8) // Draw a circle at mouse position with radius 4 and color 8
func GetMouseXY() (int, int) {
return mouseX, mouseY
}