Add new moods (happy, cry, poop) with animations and ChangeMood function in Zukitchi widget

This commit is contained in:
Arindy 2026-01-02 16:56:47 +01:00
parent 325144e0d9
commit 21ac083ef0
3 changed files with 168 additions and 145 deletions

View File

@ -296,8 +296,10 @@ func (widget *MoodText) Keyboard(k *terminalapi.Keyboard, _ *widgetapi.EventMeta
widget.WriteMood(2) widget.WriteMood(2)
case '3': case '3':
widget.WriteMood(3) widget.WriteMood(3)
ChangeMood("happy")
default: default:
widget.WriteMood(-1) widget.WriteMood(-1)
ChangeMood("cry")
} }
return widget.drawTable() return widget.drawTable()
} }

View File

@ -46,3 +46,18 @@ func draw(widget *text.Text) error {
lastFrame = time.Now() lastFrame = time.Now()
return nil return nil
} }
func ChangeMood(mood string) {
pet.ChangeMood(mood)
go func() {
ticker := time.NewTicker(10 * time.Second)
for {
select {
case <-ticker.C:
pet.ChangeMood("idle")
ticker.Stop()
}
}
}()
}

View File

@ -6,6 +6,9 @@ import (
) )
var idleFrames = []string{idle0, idle1, idle2, idle1} var idleFrames = []string{idle0, idle1, idle2, idle1}
var happyFrames = []string{happy9, happy1, happy2, happy1}
var poopFrames = []string{poop0, poop1}
var cryFrames = []string{cry0, cry1}
var sleepFrames = []string{sleep0, sleep1} var sleepFrames = []string{sleep0, sleep1}
type Zukitchi struct { type Zukitchi struct {
@ -42,6 +45,15 @@ func (a *Zukitchi) ChangeMood(mood string) {
case "idle": case "idle":
a.animation = idleFrames a.animation = idleFrames
break break
case "happy":
a.animation = happyFrames
break
case "poop":
a.animation = poopFrames
break
case "cry":
a.animation = cryFrames
break
case "sleep": case "sleep":
default: default:
a.animation = sleepFrames a.animation = sleepFrames
@ -136,6 +148,142 @@ const idle2 = `
` `
const happy9 = `
`
const happy1 = `
`
const happy2 = `
`
const poop0 = `
`
const poop1 = `
`
const cry0 = `
`
const cry1 = `
`
const sleep0 = ` const sleep0 = `
@ -253,63 +401,7 @@ const image8 = `
` `
const image9 = `
`
const image10 = `
`
const image11 = `
`
const image12 = ` const image12 = `
@ -386,44 +478,6 @@ const image15 = `
` `
const image16 = `
`
const image17 = `
`
const image27 = ` const image27 = `
@ -958,44 +1012,7 @@ const image56 = `
` `
const image57 = `
`
const image58 = `
`
const image59 = ` const image59 = `
@ -1053,18 +1070,7 @@ const image61 = `
` `
const image62 = `
`
const image63 = `
`
const image64 = `
`
const image65 = `
`
const image66 = ` const image66 = `