Toggle Navigation
Hatchery
Eggs
Board game Dice
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import rgb, time, defines, random, buttons rgb.clear() NOdice = 1 #number of dice Startnumb = 1 #starting rand number Maxnumb = 6 #max rand number of 1 dice (so when 2 dice are used max 6 gives 12) animation = 0 # give direct number or little animation setup = 0 selected = 0 #menucounter numberholder = 0 #when more then 1 dice is used #Buttons are copyed form DotDotDot tag by Tiger_Ace, because i am lazy # variables for buttons buttonup = 0 buttondown = 0 buttonright = 0 buttonleft = 0 buttona = 0 # button readout def rateup(button_is_down): if button_is_down: global buttonup buttonup = 1 pass buttons.register(defines.BTN_UP, rateup) def ratedown(button_is_down): if button_is_down: global buttondown buttondown = 1 pass buttons.register(defines.BTN_DOWN, ratedown) def colorright(button_is_down): if button_is_down: global buttonright buttonright = 1 pass buttons.register(defines.BTN_RIGHT, colorright) def colorleft(button_is_down): if button_is_down: global buttonleft buttonleft = 1 pass buttons.register(defines.BTN_LEFT, colorleft) def textb(button_is_down): if button_is_down: global buttona buttona = 1 pass buttons.register(defines.BTN_A, textb) #some early debug for my self #rgb.text(str(NOdice), (255, 255, 255),(0,1)) #rgb.text(str(Startnumb), (255, 255, 255),(12,1)) #rgb.text(str(Maxnumb), (255, 255, 255),(27,1)) #time.sleep(1) #rgb.clear() #setup def updatedisplay(): #print(11) rgb.clear() if selected == 0: rgb.scrolltext("Number of dice:", (255, 255, 255), (0, 1),20) rgb.text(str(NOdice), (255, 255, 255),(21,1)) print(12) if selected == 1: rgb.scrolltext("Min number:", (255, 255, 255), (0, 1),20) rgb.text(str(Startnumb), (255, 255, 255),(21,1)) print(13) if selected == 2: rgb.scrolltext("Max number:", (255, 255, 255), (0, 1),20) rgb.text(str(Maxnumb), (255, 255, 255),(21,1)) updatedisplay() while setup == 0: time.sleep(0.05) if buttonleft and selected != 0: #move in menus, with a little bug somewhere selected = selected -1 buttonleft = 0 updatedisplay() print(1) if buttonright and selected < 2: selected = selected +1 buttonright = 0 updatedisplay() print(2) if selected == 0: #change number of dice if buttonup: NOdice = NOdice + 1 buttonup = 0 updatedisplay() print(3) elif buttondown: NOdice = NOdice - 1 buttondown = 0 updatedisplay() print(4) elif selected == 1: #change min number, has to be smaller then max, no check for this yet. if buttonup: Startnumb = Startnumb + 1 buttonup = 0 updatedisplay() print(5) elif buttondown: Startnumb = Startnumb - 1 buttondown = 0 updatedisplay() print(6) elif selected == 2: #change max number if buttonup: Maxnumb = Maxnumb + 1 buttonup = 0 updatedisplay() print(7) elif buttondown: Maxnumb = Maxnumb - 1 buttondown = 0 updatedisplay() print(8) else: selected = 0 if buttona == 1 and Maxnumb < Startnumb: rgb.clear() rgb.scrolltext("Max can't be smaller then Min", (255, 0, 0), (0, 1)) buttona = 0 time.sleep(8.5) updatedisplay() elif buttona == 1 and Startnumb < Maxnumb: # exit setup buttona = 0 setup = 1 while True: #program if buttona == 1: numberholder = 0 if animation == 0: # maybe will add to menu to turn it off for x in range(13): rgb.clear() rgb.text(str(random.randint(Startnumb,Maxnumb)), (255, 255, 255),(x,1)) time.sleep(0.1) for i in range(NOdice): #generate the shown number. *number of dice numberholder = numberholder + random.randint(Startnumb,Maxnumb) rgb.clear() rgb.text(str(numberholder), (255, 255, 255),(13,1)) time.sleep(2) #anti cheat timer, maybe wil add to menu buttona = 0 time.sleep(0.5)