Starting to experiment with rays and collisions. New scene to demonstrate.

This commit is contained in:
dbenavid
2023-09-05 19:25:13 -04:00
parent 6cd2b8186c
commit 10d6cad4a3

View File

@@ -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
}