-
• #2
Wow, that's great! Thanks for posting up... I love the apple-eating animation :)
-
• #3
very neat!
-
• #4
The apple-eating animation is a hollow circle that grows from the point of the apple and fades its colour out on each step.
I added a helper function to draw the circle that was fast enough not to affect the frame rate. I don't know much C but I can try port it to be used in the Espruino graphic library.m.drawCircle = function(posX, posY, radX){ var radY = 0; // Decision criterion divided by 2 evaluated at radX=radX, radY=0 . var decisionOver2 = 1 - radX; while (radX >= radY) { m.setPixel(radX + posX, radY + posY); m.setPixel(radY + posX, radX + posY); m.setPixel(-radX + posX, radY + posY); m.setPixel(-radY + posX, radX + posY); m.setPixel(-radX + posX, -radY + posY); m.setPixel(-radY + posX, -radX + posY); m.setPixel(radX + posX, -radY + posY); m.setPixel(radY + posX, -radX + posY); radY++; if (decisionOver2 <= 0) { // Change in decision criterion for radY -> radY+1 . decisionOver2 += 2 * radY + 1; } else { radX--; // Change for radY -> radY+1, radX -> radX-1 . decisionOver2 += 2 * (radY - radX) + 1; } } };
-
• #5
Nice - thanks! I've just made an issue for it.
If you want to add to Espruino that's be great (but you'd have to get it so you could compile it yourself). Otherwise when things calm down a bit for me it shouldn't take long to put it in :)
Hello, I've just finished writing my version on Snake on Espruino to be played on a 15x15 RGB LED martix board (I can do a write up on how I built it if anyone would be interested).
For the controls I used an analog 2-axis thumb joystick wired onto the Espruino Pico.
You can find the code on GitHub and use it how ever you wish, I've added lots of comments explaining what's going on and by changing the settings at the beginning you'll easily be able to get it working on any similar devices.
Code: https://github.com/owenmcateer/espruino-snake
Demo video https://www.youtube.com/watch?v=C0IXREfDMOk