diff options
Diffstat (limited to 'objs')
| -rw-r--r-- | objs/cursor.go | 31 | ||||
| -rw-r--r-- | objs/paddle.go | 26 | ||||
| -rw-r--r-- | objs/root.go | 25 |
3 files changed, 82 insertions, 0 deletions
diff --git a/objs/cursor.go b/objs/cursor.go new file mode 100644 index 0000000..b1fdca3 --- /dev/null +++ b/objs/cursor.go @@ -0,0 +1,31 @@ +package objs + +import ( + "github.com/Zyko0/go-sdl3/sdl" + "ponger/ecs" + "ponger/input" +) + +type Cursor struct { + *ecs.GameObject +} + +func (c *Cursor) Render(renderer *sdl.Renderer) { + renderer.SetDrawColor(255, 0, 0, 255) + renderer.RenderPoint(c.Position.X, c.Position.Y) +} + +func (c *Cursor) Process(ev input.Event) { + c.Position.X += ev.Dx + c.Position.Y += ev.Dy +} + +func (c *Cursor) GO() *ecs.GameObject { + return c.GameObject +} + +func NewCursor() ecs.IsGameObject { + return &Cursor{ + GameObject: &ecs.GameObject{}, + } +} diff --git a/objs/paddle.go b/objs/paddle.go new file mode 100644 index 0000000..e997ff9 --- /dev/null +++ b/objs/paddle.go @@ -0,0 +1,26 @@ +package objs + +import ( + "github.com/Zyko0/go-sdl3/sdl" + "ponger/ecs" + "ponger/input" +) + +type Paddle struct { + *ecs.GameObject +} + +func (p *Paddle) Process(ev input.Event) { + //TODO implement me + panic("implement me") +} + +func NewPaddle() *ecs.GameObject { + p := &Paddle{ + GameObject: &ecs.GameObject{ + Position: sdl.FPoint{}, + Children: nil, + }, + } + return p.GameObject +} diff --git a/objs/root.go b/objs/root.go new file mode 100644 index 0000000..59e0c6a --- /dev/null +++ b/objs/root.go @@ -0,0 +1,25 @@ +package objs + +import ( + "github.com/Zyko0/go-sdl3/sdl" + "ponger/ecs" +) + +type Root struct { + *ecs.GameObject +} + +func (root *Root) Render(r *sdl.Renderer) { + r.SetDrawColor(255, 255, 255, 255) + r.Clear() +} + +func NewRoot(children ...ecs.IsGameObject) ecs.IsGameObject { + r := &Root{ + GameObject: &ecs.GameObject{ + Position: sdl.FPoint{}, + Children: children, + }, + } + return r.GameObject +} |
