Compare commits

..

4 Commits

Author SHA1 Message Date
dbenavid
220e0ed712 Ray scene loading. 2023-09-05 19:29:11 -04:00
dbenavid
09de5bf455 Cleanup on subtext. 2023-09-05 19:28:25 -04:00
dbenavid
296f56df72 Applying reposition test results to dynamic bg. 2023-09-05 19:27:53 -04:00
dbenavid
10d6cad4a3 Starting to experiment with rays and collisions. New scene to demonstrate. 2023-09-05 19:25:13 -04:00
4 changed files with 72 additions and 8 deletions

View File

@@ -37,7 +37,8 @@ func loadScenes(m *groovy.Manager) {
//loadMenu(m)
//loadNoise(m)
//loadSplashpad(m)
loadParallax(m)
//loadParallax(m)
loadRays(m)
//reset the manager to start scene 1
m.ResetScenes()
@@ -95,3 +96,8 @@ func loadParallax(m *groovy.Manager) {
m.AddScene(&sceneParallax)
sceneParallax.InitializeParallax()
}
func loadRays(m *groovy.Manager) {
sceneRays := splashmenu.NewRays()
m.AddScene(&sceneRays)
}

View File

@@ -175,6 +175,13 @@ func (p *Parallax) DrawDynamicBackground(screen *ebiten.Image) {
xd := (x0-float64(x))/DEBRIS_SCALE_DIST*float64(k+1) + x0 - float64(p.increment*k)/FLOAT_SCALE
yd := (y0-float64(y))/DEBRIS_SCALE_DIST*float64(k+1) + y0 - float64(p.increment*k)/FLOAT_SCALE
adjustX := float64(p.Dimensions.Width)
adjustY := float64(p.Dimensions.Height)
intX := adjustX * math.Floor(float64(p.increment)/adjustX)
intY := adjustY * math.Floor(float64(p.increment)/adjustY)
xd = xd + intX
yd = yd + intY
op = &ebiten.DrawImageOptions{}
op.GeoM.Translate(xd, yd)
//op.GeoM.Rotate(math.Pi / 180 * float64(p.increment))
@@ -239,8 +246,10 @@ func (p *Parallax) RepositionTest(screen *ebiten.Image) {
x0 := float32(p.Dimensions.Width / 2)
y0 := float32(p.Dimensions.Height / 2)
xd := float32(100.0)
yd := float32(100.0)
adjustment := float32(400.0)
xd := adjustment / 4.0
yd := adjustment / 4.0
//connect the dots
path.MoveTo(x0-xd, y0-yd)
@@ -272,11 +281,10 @@ func (p *Parallax) RepositionTest(screen *ebiten.Image) {
roX := float64(178 / 4)
roY := float64(229 / 4)
startX := float64(maxX) + roX
startX := float64(maxX) + roX*2
startY := float64(y0) + roY/2
adjustment := 400.0
currentX := startX - float64(p.increment) + adjustment*math.Floor(float64(p.increment)/adjustment)
currentX := startX - float64(p.increment) + float64(adjustment)*math.Floor(float64(p.increment)/float64(adjustment))
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(.5, .5)

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
}

View File

@@ -10,7 +10,8 @@ import (
)
const (
splashText = "schmoopysoft"
splashText = "schmoopysoft®"
splashSubtext = "\"how was the gravy\"\n- christorpher hollick"
)
type Splash struct {
@@ -53,7 +54,7 @@ func (s *Splash) Draw(screen *ebiten.Image) {
y := s.Dimensions.Height / 2
text.Draw(screen, splashText, splashmenu.SplashFont.MegaTitle, x, y, color.White)
text.Draw(screen, "\"how was the gravy\"\n- christorpher hollick", splashmenu.SplashFont.Title, x, y+40, color.White)
text.Draw(screen, splashSubtext, splashmenu.SplashFont.Title, x, y+40, color.White)
}
func (s *Splash) SetEventHandler(event groovy.SceneEvent, f func()) {