Toggle Navigation
Hatchery
Eggs
MultiDice
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import rgb, random, buttons, defines def display(value, pos): offset = pos * 5 + 1 border = (0x33, 0x33, 0x33) rgb.pixel(border,(offset+1,2)) rgb.pixel(border,(offset+2,2)) rgb.pixel(border,(offset+3,2)) rgb.pixel(border,(offset+1,3)) rgb.pixel(border,(offset+2,3)) rgb.pixel(border,(offset+3,3)) rgb.pixel(border,(offset+1,4)) rgb.pixel(border,(offset+2,4)) rgb.pixel(border,(offset+3,4)) if pos < 2: color = (0xff, 0xff, 0xff) #white border = (0x33, 0x33, 0x33) elif pos == 2: color = (0xff, 0x0, 0x0) #red elif pos == 3: color = (0xff, 0xff, 0x0) #yellow elif pos == 4: color = (0x0, 0xff, 0x0) #green elif pos == 5: color = (0x0, 0x0, 0xff) #blue if value in (4,5,6): rgb.pixel(color,(offset+1,2)) rgb.pixel(color,(offset+3,4)) if value in (2,3,4,5,6): rgb.pixel(color,(offset+3,2)) rgb.pixel(color,(offset+1,4)) if value == 6: rgb.pixel(color,(offset+1,3)) rgb.pixel(color,(offset+3,3)) if value in (1,3,5): rgb.pixel(color,(offset+2,3)) def roll(button_is_down): if button_is_down: rgb.clear() for i in range(6): display(random.randint(1,6), i) pass buttons.register(defines.BTN_UP, roll) buttons.register(defines.BTN_DOWN, roll) buttons.register(defines.BTN_LEFT, roll) buttons.register(defines.BTN_RIGHT, roll)