@allObjects idea of adding a black triangle to the circle sounds great.
Basically you need to combine sin and cos to turn the angle you want into coordinates.
I know it's a bit hard to know where to get started, but maybe try:
function drawPacMan(ang, clear, mouthAngle) {
ang = ang*Math.PI/180;
g.setColor(clear?0:0xFD20); // black/orange
var r = 108;
var x = CenterX + Math.sin(ang)*r;
var y = CenterY - Math.cos(ang)*r;
g.fillCircle(x,y,7);
if (clear) return;
g.setColor(0); // black
var a = mouthAngle*Math.PI/180;
g.fillPoly([
x,y,
x+Math.cos(ang-a)*12, y+Math.sin(ang-a)*12,
x+Math.cos(ang+a)*12, y+Math.sin(ang+a)*12
]);
}
var lastPacManAngle = 0;
setInterval(function cb(){
d = new Date();
let s = d.getSeconds() + (d.getMilliseconds()/1000);
let ang = s*6;
drawPacMan(lastPacManAngle, true); // remove old
drawPacMan(ang, false, 10+10*Math.sin(s*10)); // add new
lastPacManAngle = ang;
},100);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - what you've got in the link looks great!
@allObjects idea of adding a black triangle to the circle sounds great.
Basically you need to combine sin and cos to turn the angle you want into coordinates.
I know it's a bit hard to know where to get started, but maybe try: