Toggle Navigation
Hatchery
Eggs
Puddle
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import display, keypad, virtualtimers pool = [{"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0}, {"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0}, {"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0}, {"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0},{"age":7,"seq":0}] def indexToXY(index): x = index % 4 y = index // 4 return [x,y] def doDraw(): global pool index = 0 display.drawFill(0) for sector in pool: x, y = indexToXY(index) index += 1 if sector['age'] <= 7: drawDrop(x,y,sector['age']) sector['age']+= 1 display.flush() return 50 def drawDrop(x,y,age): colour = 65535 display.drawCircle(x,y,age,0,360,False,colour) if age > 1: display.drawCircle(x,y,age-1,0,360,False,int(colour/2)) display.drawCircle(x,y,age+1,0,360,False,int(colour/3)) def on_key(key_index, pressed): global pool if not pressed: pool[key_index]["age"] = 0 keypad.add_handler(on_key) virtualtimers.begin(50) virtualtimers.new(50, doDraw)