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.
48 lines
992 B
Go
48 lines
992 B
Go
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)
|
||
}
|
||
}
|