Add navigation components 131-150; pixel Pad, Finish, Park, Since
This commit is contained in:
63 files changed
+2776
-87
No files matched your search
@@ -20,7 +20,7 @@ func Achievement(c *ui.Context, title string, o AchievementOptions) *ui.Element
|
||||
w := pixel.Or("Achievement Width", o.Width, 200)
|
||||
e := ui.Box(c)
|
||||
// Ten steps a second; in by 5, gone by 40.
|
||||
step := since(c, k, cue(e, k, o.Cue), 10, 40)
|
||||
step := k.Since(c, cue(e, k, o.Cue), 10, 40)
|
||||
if step >= 40 {
|
||||
return e
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func ComboCounter(c *ui.Context, count int, o ComboCounterOptions) *ui.Element {
|
||||
if count <= 0 {
|
||||
return e
|
||||
}
|
||||
pop := !k.Reduce() && since(c, k, s.at, 10, 2) < 2
|
||||
pop := !k.Reduce() && k.Since(c, s.at, 10, 2) < 2
|
||||
n, tag := "×"+strconv.Itoa(count), k.Msg("combo")
|
||||
w := pixel.Measure(n)*3 + 6 + pixel.Measure(tag)*2 + 2
|
||||
return e.Role(ui.RoleStatus).Label(n+" "+tag).Size(k.D(w), k.D(3*pixel.LineHeight+2)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ func CountUp(c *ui.Context, value int, o CountUpOptions) *ui.Element {
|
||||
shown := func() int {
|
||||
step := 8
|
||||
if !k.Reduce() {
|
||||
step = since(c, k, s.at, 15, 8)
|
||||
step = k.Since(c, s.at, 15, 8)
|
||||
}
|
||||
return s.from + (s.to-s.from)*step/8
|
||||
}
|
||||
|
||||
@@ -52,15 +52,3 @@ func cue(e *ui.Element, k pixel.Kit, n int) time.Time {
|
||||
}
|
||||
return s.at
|
||||
}
|
||||
|
||||
// since counts steps at fps from t, up to done.
|
||||
func since(c *ui.Context, k pixel.Kit, t time.Time, fps, done int) int {
|
||||
if t.IsZero() {
|
||||
return done
|
||||
}
|
||||
n := int(k.Now().Sub(t) * time.Duration(fps) / time.Second)
|
||||
if n < done {
|
||||
k.Tick(c, fps)
|
||||
}
|
||||
return min(n, done)
|
||||
}
|
||||
+1
-1
@@ -30,7 +30,7 @@ func LevelUp(c *ui.Context, level int, o LevelUpOptions) *ui.Element {
|
||||
}
|
||||
s.level = level
|
||||
// Ten steps a second: six slide in, twenty stay.
|
||||
step := since(c, k, s.at, 10, 26)
|
||||
step := k.Since(c, s.at, 10, 26)
|
||||
if step >= 26 {
|
||||
return e
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ func ReadyGo(c *ui.Context, o ReadyGoOptions) ReadyGoResult {
|
||||
*s = ready{n: o.Cue, at: k.Now()}
|
||||
}
|
||||
res := ReadyGoResult{Element: e}
|
||||
sec := since(c, k, s.at, 10, 40) / 10
|
||||
sec := k.Since(c, s.at, 10, 40) / 10
|
||||
// Done comes once, even when time jumps past GO!.
|
||||
if sec >= 3 && !s.said && !s.at.IsZero() {
|
||||
s.said, res.Done = true, true
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ func Shake(c *ui.Context, o ShakeOptions, content func()) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
e := ui.Box(c)
|
||||
dx := 0
|
||||
if step := since(c, k, cue(e, k, o.Cue), 20, len(shakes)-1); !k.Reduce() {
|
||||
if step := k.Since(c, cue(e, k, o.Cue), 20, len(shakes)-1); !k.Reduce() {
|
||||
dx = shakes[step]
|
||||
}
|
||||
return e.Padding(0, k.D(2-dx), 0, k.D(2+dx)).Children(content)
|
||||
|
||||
Reference in new issue
Block a user