This is a Pokitto drawing loop implemented in Python
Credits of the Pokitto bitmap to @spinal !
The Python code (in simulator) as follows:
import umachine as machine
import framebuf
import urandom as random
# screen buffer
w = 220
h = 176
buf = bytearray(w * h // 2)
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS4_HMSB) # 4 bit color depth
# pokitto picture
w2 = 32
h2 = 32
pokittoPixels = [
0x00,0x00,0x03,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x30,0x00,0x00,
0x00,0x00,0x32,0x23,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x23,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x32,0x23,0x00,0x00,
0x00,0x00,0x33,0x32,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x33,0x00,0x00,
0x00,0x00,0x32,0x22,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x31,0x11,0x33,0x11,0x11,0x33,0x11,0x13,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x31,0x13,0x11,0x31,0x13,0x11,0x31,0x13,0x22,0x23,0x00,0x00,
0x00,0x33,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x33,0x00,
0x03,0x22,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x22,0x30,
0x03,0x22,0x32,0x22,0x31,0x11,0x31,0x11,0x11,0x13,0x11,0x13,0x22,0x23,0x22,0x30,
0x00,0x33,0x32,0x22,0x31,0x11,0x13,0x33,0x33,0x31,0x11,0x13,0x22,0x23,0x33,0x00,
0x00,0x00,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x31,0x11,0x11,0x11,0x11,0x11,0x11,0x13,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x23,0x32,0x22,0x22,0x22,0x22,0x22,0x33,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x23,0x32,0x22,0x22,0x22,0x22,0x22,0x33,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x23,0x33,0x33,0x32,0x22,0x22,0x33,0x32,0x33,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x23,0x33,0x33,0x32,0x22,0x22,0x33,0x32,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x23,0x32,0x22,0x22,0x22,0x33,0x32,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x23,0x32,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x32,0x22,0x22,0x22,0x22,0x33,0x32,0x22,0x22,0x22,0x22,0x23,0x00,0x00,
0x00,0x00,0x33,0x32,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x33,0x00,0x00,
0x00,0x00,0x32,0x23,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x23,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x32,0x23,0x00,0x00,
0x00,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,
0x00,0x00,0x32,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x23,0x00,0x00,
0x00,0x00,0x32,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x23,0x00,0x00,
0x00,0x00,0x03,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x30,0x00,0x00,
]
pokittoBuf = bytearray(pokittoPixels)
pokittoFBuf = framebuf.FrameBuffer(pokittoBuf, w2, h2, framebuf.GS4_HMSB)
# Event / update loop
while( machine.isRunningPokitto() ):
if( machine.updatePokitto()):
x = random.getrandbits(7) + 50
y = random.getrandbits(7) + 20
fbuf.blit(pokittoFBuf, x, y, 0); # 0 is transparent color
fbuf.show_framebuf()
So now it runs the Pokitto event/update loop in Python. Next I will implement bindings of Pokitto key event reading in Python.
One thing to consider in the future is porting of some gaming library over uPy (e.g. PyGame), or rather a subset of it (âuPyGameâ). I would not like us to have a Pokitto custom gaming or gfx API in Python, but something also other MCU boards can use and build games on, and something that is familiar to Python game devs.