diff --git a/animateDoorbell.go b/animateDoorbell.go index 4b20c75..9438861 100644 --- a/animateDoorbell.go +++ b/animateDoorbell.go @@ -13,6 +13,16 @@ type Doorbell struct { image image.Image } +func (a *Animation) animateDoorbell() { + if a.countDown > 0 { + a.ctx.DrawImageAnchored(a.doorbell.image, 0, 0, 0, 0) + a.countDown -= 50 + } else { + a.doorbell = Doorbell{} + a.countDown = 5000 + a.ctx.Pop() + } +} func loadImage(imgType string, img string, a *Animation) { baseImage, _ := b64.StdEncoding.DecodeString(img) bigImage, _, _ := image.Decode(bytes.NewReader(baseImage)) diff --git a/board.go b/board.go index 9070501..67df72c 100644 --- a/board.go +++ b/board.go @@ -48,14 +48,7 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) { var incoming incomingMessage switch { case a.doorbell != (Doorbell{}): - if a.countDown > 0 { - a.ctx.DrawImageAnchored(a.doorbell.image, 0, 0, 0, 0) - a.countDown -= 50 - } else { - a.doorbell = Doorbell{} - a.countDown = 5000 - a.ctx.Pop() - } + a.animateDoorbell() default: a.animateMario() }