Starting to experiment with rays and collisions. New scene to demonstrate.
This commit is contained in:
49
examples/splashmenu/scenes/rays.go
Normal file
49
examples/splashmenu/scenes/rays.go
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user