Created
January 9, 2020 06:39
-
-
Save rozek/3bd97d96f0c7391b9184d5338258ed0c to your computer and use it in GitHub Desktop.
Bangle.js: animates a little Pacman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bangle.setLCDMode('120x120'); | |
g.clear(); | |
const Width = g.getWidth(), CenterX = Width/2; | |
const Height = g.getHeight(), CenterY = Height/2; | |
g.setColor(1,1,0); | |
let AnimationList = [Graphics.createImage(` | |
**** | |
****** | |
****** | |
** | |
****** | |
**** | |
`), Graphics.createImage(` | |
**** | |
****** | |
** | |
** | |
****** | |
**** | |
`), Graphics.createImage(` | |
**** | |
*** | |
** | |
** | |
*** | |
**** | |
`)]; | |
AnimationList.push(AnimationList[1]); | |
let AnimationIndex = 0; | |
function animateImage () { | |
g.drawImage(AnimationList[AnimationIndex], CenterX,CenterY); | |
g.flip(); | |
AnimationIndex++; | |
if (AnimationIndex >= AnimationList.length) { | |
AnimationIndex = 0; | |
} | |
} | |
setInterval(animateImage,300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment