From 06dd690345a02ad5f158138b2d6597220b716e38 Mon Sep 17 00:00:00 2001 From: ewy Date: Thu, 13 Aug 2026 13:59:25 +0200 Subject: add stuff --- input/input.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 input/input.go (limited to 'input/input.go') diff --git a/input/input.go b/input/input.go new file mode 100644 index 0000000..94f4e56 --- /dev/null +++ b/input/input.go @@ -0,0 +1,30 @@ +package input + +import "ponger/ecs" + +type DeviceID int + +type Event struct { + ecs.Event + Which DeviceID + Dx, Dy float32 + JustPressed, JustReleased, IsPressed bool +} + +type Handler interface { + Process(ev Event) +} + +func ProcessTree(root any, ev Event) { + if inp, ok := root.(Handler); ok { + inp.Process(ev) + } + if g, ok := root.(*ecs.GameObject); ok { + for _, c := range g.Children { + if c == nil { + continue + } + ProcessTree(c, ev) + } + } +} -- cgit v1.3.1