Toggle Navigation
Hatchery
Eggs
PacTest
__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_x = 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 pink_ghost_8x8_left = [ 0x000000FF, 0x000000FF, 0x57002DFF, 0xCA0C79FF, 0xCA0C79FF, 0x57002DFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x7A264CFF, 0xCA247BFF, 0xCE007AFF, 0xCE007AFF, 0xCA247BFF, 0x7A264CFF, 0x000000FF, 0x3D2731FF, 0xDECDD6FF, 0xEBD3DDFF, 0xD02780FF, 0xDECDD6FF, 0xEBD3DDFF, 0x7A0045FF, 0x000000FF, 0x8F2567FF, 0x7291BDFF, 0xEDECF1FF, 0xCD488AFF, 0x748EBDFF, 0xECECF1FF, 0xD04787FF, 0xA1005CFF, 0xCF0076FF, 0xD483A7FF, 0xDA8DACFF, 0xCE0076FF, 0xD481A6FF, 0xDA8EADFF, 0xCF007AFF, 0xCF007AFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xD00A7DFF, 0xB60A6DFF, 0xD00A7DFF, 0xB60A6DFF, 0xB60A6DFF, 0xD00A7DFF, 0xB60A6DFF, 0xD00A7DFF, 0xD00A7DFF, 0x000000FF, 0xD00A7DFF, 0xB60A6DFF, 0xB60A6DFF, 0xD00A7DFF, 0x000000FF, 0xD00A7DFF ] pink_ghost_8x8_right = [ 0x000000FF, 0x000000FF, 0x57002DFF, 0xCA0C79FF, 0xCA0C79FF, 0x57002DFF, 0x000000FF, 0x000000FF, 0x000000FF, 0x7A264CFF, 0xCA247BFF, 0xCE007AFF, 0xCE007AFF, 0xCA247BFF, 0x7A264CFF, 0x000000FF, 0x000000FF, 0x7A0045FF, 0xEBD3DDFF, 0xDECDD6FF, 0xD02780FF, 0xEBD3DDFF, 0xDECDD6FF, 0x3D2731FF, 0xA1005CFF, 0xD04787FF, 0xECECF1FF, 0x748EBDFF, 0xCD488AFF, 0xEDECF1FF, 0x7291BDFF, 0x8F2567FF, 0xCF007AFF, 0xCF007AFF, 0xDA8EADFF, 0xD481A6FF, 0xCE0076FF, 0xDA8DACFF, 0xD483A7FF, 0xCF0076FF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xCE107CFF, 0xD00A7DFF, 0xB60A6DFF, 0xD00A7DFF, 0xB60A6DFF, 0xB60A6DFF, 0xD00A7DFF, 0xB60A6DFF, 0xD00A7DFF, 0xD00A7DFF, 0x000000FF, 0xD00A7DFF, 0xB60A6DFF, 0xB60A6DFF, 0xD00A7DFF, 0x000000FF, 0xD00A7DFF ] def input_left(pressed): global current_direction current_direction = 0 def input_right(pressed): global current_direction current_direction = 1 def draw_ghost(): global current_x, current_direction rgb.clear() if current_direction == 0: rgb.image(pink_ghost_8x8_left, (current_x,0), (8,8)) else: rgb.image(pink_ghost_8x8_right, (current_x,0), (8,8)) # init button callbacks #buttons.register(UP, input_up) #buttons.register(DOWN, input_down) buttons.register(LEFT, input_left) buttons.register(RIGHT, input_right) #buttons.register(B, input_B) #buttons.register(A, input_A) rgb.background((0,0,0)) while True: draw_ghost() sleep(0.1) # set new position if current_direction == 0 and current_x > -8: current_x -= 1 continue if current_direction == 0 and current_x <= -1: current_x = 36 continue if current_direction == 1 and current_x >= 37: current_x = -8 continue current_x += 1