package splashmenu import ( "cosmos/diego/groovy" splashmenu "cosmos/diego/groovy/examples/splashmenu/fonts" "image/color" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/text" ) type Splash struct { Dimensions groovy.Area bgcolor color.RGBA increment int events map[groovy.SceneEvent]func() } func NewSplash() Splash { return Splash{ bgcolor: color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}, events: make(map[groovy.SceneEvent]func()), } } func (s *Splash) Update() error { s.increment++ s.bgcolor.R = (s.bgcolor.R - 2) % 0xFF s.bgcolor.G = (s.bgcolor.G - 2) % 0xFF s.bgcolor.B = (s.bgcolor.B - 2) % 0xFF if s.bgcolor.R == 0x00 { s.events[groovy.COMPLETED]() //scene cleanup (for next time) s.increment = 0 } return nil } func (s *Splash) Draw(screen *ebiten.Image) { screen.Fill(s.bgcolor) text.Draw(screen, "splash", splashmenu.SplashFont.Splash, 40, 40, color.White) } func (s *Splash) SetEventHandler(event groovy.SceneEvent, f func()) { s.events[event] = f } // sets sene dimensions func (s *Splash) SetDimensions(a groovy.Area) { s.Dimensions = a }