From 48215d06a6cc0753a839e58c3403d34f69c250d4 Mon Sep 17 00:00:00 2001 From: ewy Date: Fri, 14 Aug 2026 12:32:05 +0200 Subject: add components in addition to gameobject interfaces --- ecs/component.go | 7 +++++++ ecs/event.go | 6 ------ ecs/gameobject.go | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 ecs/component.go delete mode 100644 ecs/event.go (limited to 'ecs') diff --git a/ecs/component.go b/ecs/component.go new file mode 100644 index 0000000..f42f2e7 --- /dev/null +++ b/ecs/component.go @@ -0,0 +1,7 @@ +package ecs + +import "ponger/events" + +type Component interface { + Process(delta events.Delta, object *GameObject) +} diff --git a/ecs/event.go b/ecs/event.go deleted file mode 100644 index 00904d9..0000000 --- a/ecs/event.go +++ /dev/null @@ -1,6 +0,0 @@ -package ecs - -type Event struct { - // Delta is time between events in ms - Delta uint64 -} diff --git a/ecs/gameobject.go b/ecs/gameobject.go index a2718c3..86429d7 100644 --- a/ecs/gameobject.go +++ b/ecs/gameobject.go @@ -1,10 +1,14 @@ package ecs -import "github.com/Zyko0/go-sdl3/sdl" +import ( + "fmt" + "github.com/Zyko0/go-sdl3/sdl" +) type GameObject struct { - Position sdl.FPoint - Children []IsGameObject + Position sdl.FPoint + Children []IsGameObject + Components []Component } func (g *GameObject) GO() *GameObject { @@ -14,3 +18,9 @@ func (g *GameObject) GO() *GameObject { type IsGameObject interface { GO() *GameObject } + +func (g *GameObject) Safe(err error) { + if err != nil { + fmt.Printf("%v\n", err.Error()) + } +} -- cgit v1.3.1