cleanup
build rgb-board / build (push) Successful in 8m47s Details

main
Nathan Wagner 11 months ago
parent 476ed823bc
commit 1093a2c1b2

@ -54,7 +54,7 @@ func (a *Animation) animateMario() {
defer a.updateMarioPosition() defer a.updateMarioPosition()
a.ctx.SetColor(color.Black) a.ctx.SetColor(color.Black)
a.ctx.Clear() a.ctx.Clear()
if a.dir.X == 1 { if a.mario.dir.X == 1 {
a.ctx.DrawImageAnchored(a.mario.images[a.mario.updown], a.mario.position.X, a.mario.position.Y, 0.5, 0.5) a.ctx.DrawImageAnchored(a.mario.images[a.mario.updown], a.mario.position.X, a.mario.position.Y, 0.5, 0.5)
} else { } else {
a.ctx.DrawImageAnchored(imaging.FlipH(a.mario.images[a.mario.updown]), a.mario.position.X, a.mario.position.Y, 0.5, 0.5) a.ctx.DrawImageAnchored(imaging.FlipH(a.mario.images[a.mario.updown]), a.mario.position.X, a.mario.position.Y, 0.5, 0.5)
@ -69,7 +69,7 @@ func (a *Animation) updateMarioPosition() {
if a.mario.position.Y+a.height > a.ctx.Height() { if a.mario.position.Y+a.height > a.ctx.Height() {
a.mario.dir.Y = -1 a.mario.dir.Y = -1
a.mario.updown = "marioUp" a.mario.updown = "marioUp"
} else if a.position.Y-a.height < 0 { } else if a.mario.position.Y-a.height < 0 {
a.mario.updown = "marioDown" a.mario.updown = "marioDown"
a.mario.dir.Y = 1 a.mario.dir.Y = 1
} }

@ -14,16 +14,13 @@ import (
type Animation struct { type Animation struct {
ctx *gg.Context ctx *gg.Context
position image.Point
dir image.Point
height int height int
width int width int
stroke int stroke int
updown string
mqmsg chan mqtt.Message mqmsg chan mqtt.Message
msg string msg string
mario Mario
countDown int countDown int
mario Mario
doorbell Doorbell doorbell Doorbell
} }
@ -35,11 +32,9 @@ func orchestrator(tk *rgbmatrix.ToolKit, mqMessages chan mqtt.Message) {
func animate(sz image.Point, mqMessages chan mqtt.Message) *Animation { func animate(sz image.Point, mqMessages chan mqtt.Message) *Animation {
return &Animation{ return &Animation{
ctx: gg.NewContext(sz.X, sz.Y), ctx: gg.NewContext(sz.X, sz.Y),
dir: image.Point{1, 1},
height: 8, height: 8,
width: 8, width: 8,
stroke: 8, stroke: 8,
updown: "marioUp",
mqmsg: mqMessages, mqmsg: mqMessages,
countDown: 5000, countDown: 5000,
mario: Mario{ mario: Mario{

Loading…
Cancel
Save