88 lines
1.6 KiB
Go
88 lines
1.6 KiB
Go
package gg
|
|
|
|
import (
|
|
//"github.com/hajimehoshi/ebiten/v2"
|
|
)
|
|
|
|
import "surdeus.su/core/gg/mx"
|
|
|
|
func diffEm[V comparable](s1, s2 []V) []V {
|
|
combinedSlice := append(s1, s2...)
|
|
dm := make(map[V]int)
|
|
for _, v := range combinedSlice {
|
|
if _, ok := dm[v]; ok {
|
|
// remove element later as it exist in both slice.
|
|
dm[v] += 1
|
|
continue
|
|
}
|
|
// new entry, add in map!
|
|
dm[v] = 1
|
|
}
|
|
var retSlice []V
|
|
for k, v := range dm {
|
|
if v == 1 {
|
|
retSlice = append(retSlice, k)
|
|
}
|
|
}
|
|
return retSlice
|
|
}
|
|
|
|
// The type represents event of a
|
|
// key getting pressed down.
|
|
type KeyDown struct {
|
|
Key
|
|
}
|
|
|
|
// The type represents event of a
|
|
// key getting pressed up.
|
|
type KeyUp struct {
|
|
Key
|
|
}
|
|
|
|
// The type represents event of a
|
|
// mouse button being pressed down.
|
|
type MouseButtonDown struct {
|
|
MouseButton
|
|
Position mx.Vector
|
|
}
|
|
|
|
// The type represents event of a
|
|
// mouse button being pressed up.
|
|
type MouseButtonUp struct {
|
|
MouseButton
|
|
Positon mx.Vector
|
|
}
|
|
|
|
// The type represents
|
|
// event of moving the mouse.
|
|
type MouseMove struct {
|
|
// Real and absolute deltas
|
|
// for the mouse movement.
|
|
RealDelta, AbsDelta mx.Vector
|
|
}
|
|
|
|
// The type represents event
|
|
// of a wheel change.
|
|
type WheelChange struct {
|
|
Offset mx.Vector
|
|
}
|
|
|
|
type KeyboardEvents struct {
|
|
KeyDowns []KeyDown
|
|
KeyUps []KeyUp
|
|
}
|
|
|
|
type MouseEvents struct {
|
|
ButtonDowns []MouseButtonDown
|
|
ButtonUps []MouseButtonUp
|
|
Move *MouseMove
|
|
WheelChange *WheelChange
|
|
}
|
|
|
|
type Events struct {
|
|
Keyboard KeyboardEvents
|
|
Mouse MouseEvents
|
|
}
|
|
|
|
type EventChan chan any
|
|
|