Add fx components 291-320 and the home scene; Kit.Shot, Kit.Toward
Palette cycling, sky, sun and moon, clouds, starfield, rain, snow, petals, leaves, fireflies, waterfall, ocean, campfire, lava, aurora, lightning, mountains and a season scene; scanlines, vignette, screen shake, flash, dither fades, iris wipes, dissolves, mosaics, glitches, sparkles, explosions and confetti. Home opens on a live scene in the palette's season and a strip of all eight palettes. pixel adds Canvas.Cycled, Sprite.At, SpriteOf, Kit.Toward and Kit.Shot, which spends a cue under Reduce Motion so it never replays; display exports Reduce. Gallery grids and the sidebar are one Tab stop each.
This commit is contained in:
56 files changed
+3324
-101
No files matched your search
+1
-35
@@ -1,8 +1,6 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/layout"
|
||||
@@ -14,38 +12,13 @@ type LetterboxOptions struct {
|
||||
Bar int
|
||||
}
|
||||
|
||||
type barsKey struct{}
|
||||
|
||||
// bars is the last on, its change time and step.
|
||||
type bars struct {
|
||||
on bool
|
||||
at time.Time
|
||||
from int
|
||||
}
|
||||
|
||||
// Letterbox slides cutscene bars over content in four steps.
|
||||
func Letterbox(c *ui.Context, on bool, o LetterboxOptions, content func()) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
bar := pixel.Or("Letterbox Bar", o.Bar, 16)
|
||||
var cover *ui.Element
|
||||
e := layout.Layers(c, content, func() { cover = ui.Box(c).Fill().PassThrough() })
|
||||
// First shown, the bars are already where on puts them.
|
||||
s := ui.Local(e, barsKey{}, func() bars { return bars{on: on, from: 4 * boolInt(on)} })
|
||||
// shown is the step, 0–4; turns start where it is.
|
||||
shown := func() int {
|
||||
if k.Reduce() {
|
||||
return 4 * boolInt(s.on)
|
||||
}
|
||||
if n := k.Since(c, s.at, 8, 4); s.on {
|
||||
return min(4, s.from+n)
|
||||
} else {
|
||||
return max(0, s.from-n)
|
||||
}
|
||||
}
|
||||
if on != s.on {
|
||||
s.from, s.on, s.at = shown(), on, k.Now()
|
||||
}
|
||||
h := bar * shown() / 4
|
||||
h := bar * k.Toward(c, e, on, 8, 4) / 4
|
||||
cover.Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
g.Rect(0, 0, g.W, h, pixel.Ink)
|
||||
@@ -53,10 +26,3 @@ func Letterbox(c *ui.Context, on bool, o LetterboxOptions, content func()) *ui.E
|
||||
})
|
||||
return e
|
||||
}
|
||||
|
||||
func boolInt(b bool) int {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user