12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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 {
- Downs []KeyDown
- Ups []KeyUp
- }
- type MouseEvents struct {
- Downs []MouseButtonDown
- Ups []MouseButtonUp
- Move *MouseMove
- Wheel *WheelChange
- }
- type Events struct {
- Keyboard KeyboardEvents
- Mouse MouseEvents
- }
- type EventChan chan any
|