Add game components 246-268; data.DrawSlot, Canvas.TextVeil

Health, mana and experience bars, quarter hearts, lives, a spinning
coin counter, score board, stage timer, minimap with fog, compass,
hotbar, paper-doll equipment, skill tree, skill buttons with cooldown
wipes, status effects, a boss bar, damage numbers, quest log and
tracker, party frames, character sheet, level-up screen and shop.
data exports DrawSlot so every slot looks alike; pixel adds TextVeil
for dissolving text. Messages the font cannot draw are fixed and
TestMessagesHaveGlyphs holds every message to the font.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 01:53:20 -04:00
1 parent 596c62e026
commit f48075230f
42 files changed
+3260 -26

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
package game
import (
"fmt"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
// Objective is a quest step, Have of Need (≥ 1).
type Objective struct {
Text string
Have, Need int
}
// Quest is a title and its objectives.
type Quest struct {
Title string
Objectives []Objective
}
// check fails on objectives past their need.
func (q Quest) check() {
for _, ob := range q.Objectives {
if ob.Need < 1 || ob.Have < 0 || ob.Have > ob.Need {
panic(fmt.Sprintf("game: quest %q objective %q has %d of %d", q.Title, ob.Text, ob.Have, ob.Need))
}
}
}
// done is whether every objective is met.
func (q Quest) done() bool {
for _, ob := range q.Objectives {
if ob.Have < ob.Need {
return false
}
}
return true
}
// tick marks a 7×7 box, checked when done.
func tick(g pixel.Canvas, x, y int, done bool) {
g.Frame(x, y, 7, 7, pixel.Flat, pixel.Well)
if done {
g.Line(x+1, y+3, x+2, y+5, pixel.Good)
g.Line(x+3, y+4, x+5, y+1, pixel.Good)
}
}