/
event.go
37 lines (32 loc) · 1.09 KB
/
event.go
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
package mouse
import "github.com/oakmound/oak/collision"
import (
"github.com/oakmound/oak/physics"
)
var (
// LastMouseEvent is the last triggered mouse event,
// tracked for continuous mouse responsiveness on events
// that don't take in a mouse event
LastMouseEvent Event
// LastMousePress is the last triggered mouse event,
// where the mouse event was a press.
// If TrackMouseClicks is set to false then this will not be tracked
LastMousePress Event
)
// An Event is passed in through all Mouse related event bindings to
// indicate what type of mouse event was triggered, where it was triggered,
// and which mouse button it concerns.
// this is a candidate for merging with physics.Vector
type Event struct {
X, Y float32
Button string
Event string
}
// ToSpace converts a mouse event into a collision space
func (e Event) ToSpace() *collision.Space {
return collision.NewUnassignedSpace(float64(e.X), float64(e.Y), 0.1, 0.1)
}
// ToVector returns a mouse event's position as a physics.Vector
func (e Event) ToVector() physics.Vector {
return physics.NewVector(float64(e.X), float64(e.Y))
}