From 10d6cad4a311c6e30da8f6b1a79f8a0e9e6528a3 Mon Sep 17 00:00:00 2001 From: dbenavid Date: Tue, 5 Sep 2023 19:25:13 -0400 Subject: [PATCH] Starting to experiment with rays and collisions. New scene to demonstrate. --- examples/splashmenu/scenes/rays.go | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/splashmenu/scenes/rays.go diff --git a/examples/splashmenu/scenes/rays.go b/examples/splashmenu/scenes/rays.go new file mode 100644 index 0000000..9ef7822 --- /dev/null +++ b/examples/splashmenu/scenes/rays.go @@ -0,0 +1,49 @@ +package splashmenu + +import ( + "cosmos/diego/groovy" + "image/color" + + "github.com/hajimehoshi/ebiten/v2" +) + +const ( + BGCOLOR = 0xCCCCCC +) + +type Rays struct { + events map[groovy.SceneEvent]func() + increment int + Dimensions groovy.Area + bgcolor color.RGBA +} + +func NewRays() Rays { + return Rays{ + events: make(map[groovy.SceneEvent]func()), + increment: 0, + bgcolor: color.RGBA{ + R: BGCOLOR >> 0x10 & 0xff, + G: BGCOLOR >> 0x08 & 0xff, + B: BGCOLOR >> 0x00 & 0xff, + A: 0xff, + }, + } +} + +func (r *Rays) Update() error { + r.increment++ + return nil +} + +func (r *Rays) Draw(screen *ebiten.Image) { + screen.Fill(r.bgcolor) +} + +func (r *Rays) SetDimensions(a groovy.Area) { + r.Dimensions = a +} + +func (r *Rays) SetEventHandler(event groovy.SceneEvent, f func()) { + r.events[event] = f +}