Toggle Navigation
Hatchery
Eggs
Tent Jeroen
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
from time import sleep import rgb import defines import buttons ## GLOBALS current_jeroenx = 16 current_bckgroundx = 0 current_direction = 0 # 0 = left, 1 = right # buttons UP, DOWN, LEFT, RIGHT = defines.BTN_UP, defines.BTN_DOWN, defines.BTN_LEFT, defines.BTN_RIGHT A, B = defines.BTN_A, defines.BTN_B bckground = [ 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xF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 0xFFFFFFFF, 0xFF1100FF, 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF ] jeroen_left = [ 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, 0x6e6e6eFF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0x6e6e6eFF, 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0x6e6e6eFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0xFF1100FF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0xFF1100FF, 0xFF1100FF, 0xFF1100FF, 0x000000FF, 0x000000FF, 0xFF1100FF, 0xFF1100FF, ] jeroen_right = [ 0xFF1100FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF1100FF, 0xFFFFFFFF, 0x000000FF, 0x6e6e6eFF, 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0x6e6e6eFF, 0xFFFFFFFF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0x000000FF, 0x6e6e6eFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0xFFFFFFFF, 0xFF1100FF, 0x000000FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0xFF1100FF, 0xFF1100FF, 0xFF1100FF, 0x000000FF, 0x000000FF, 0xFF1100FF, 0xFF1100FF, ] def input_left(pressed): global current_direction current_direction = 0 def input_right(pressed): global current_direction current_direction = 1 #def draw_bckground(): # global current_bckgroundx, current_direction # rgb.clear() # rgb.image(bckground, (0,0), (32,8)) def draw_jeroen(): global current_jeroenx, current_direction rgb.clear() rgb.image(bckground, (0,0), (32,8)) if current_direction == 0: rgb.image(jeroen_left, (current_jeroenx,0), (6,8)) else: rgb.image(jeroen_right, (current_jeroenx,0), (6,8)) # init button callbacks buttons.register(LEFT, input_left) buttons.register(RIGHT, input_right) #rgb.background((255,0,0)) while True: # draw_bckground() draw_jeroen() sleep(0.1) # set new position if current_direction == 0 and current_jeroenx > -8: current_jeroenx -= 1 continue if current_direction == 0 and current_jeroenx <= -1: current_jeroenx = 36 continue if current_direction == 1 and current_jeroenx >= 37: current_jeroenx = -8 continue current_jeroenx += 1