Skip to content

Instantly share code, notes, and snippets.

@rozek
Created January 9, 2020 06:39
Show Gist options
  • Save rozek/3bd97d96f0c7391b9184d5338258ed0c to your computer and use it in GitHub Desktop.
Save rozek/3bd97d96f0c7391b9184d5338258ed0c to your computer and use it in GitHub Desktop.
Bangle.js: animates a little Pacman
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