def update(): global gameOver if stage[shooterPosition][0] != 0: gameOver = True kit.clear() renderStage() kit.set_pixel(0, shooterPosition, colors[currentColor]) kit.render()
def start(): global t while True: t += 1 kit.checkControls() loop() kit.render() sleep(0.001)
def start_ap(): sta.active(False) ap.active(True) ap.config(essid='PIXEL_KIT_{}'.format(get_id())) # ap.config(authmode=3, password='******') webrepl.start() kit.set_background([0, 0, 10]) draw_ip(ap.ifconfig()[0]) kit.render()
def start(): global t global level while True: t = t + level kit.checkControls() kit.setBackground(colors[0]) loop() kit.render() sleep(0.01)
def update(): global gameOver if stage[shooterPosition][0] == 1: gameOver = True if (t % 240 - score) == 0: shift() kit.clear() renderStage() kit.setPixel(0, shooterPosition, [8, 8, 8]) kit.render()
def start(): global t reset() while True: t += 1 kit.set_background(colors[0]) if gameOver and kit.button_a.value() == 0: reset() loop() kit.render() sleep(0.01)
def loop(): global t t = t + 1 kit.check_controls() if not gameOver: if t % int(level) == 0: updateBall() kit.clear() renderFrame() kit.render() else: kit.set_background([10, 10, 0]) for i in range(0, score): kit.set_pixel(i % 16, int(i / 16), [10, 0, 0]) kit.render()
def connect(ssid, password): ap.active(False) sta.active(True) sta.connect(ssid, password) timeout = 50 while not sta.isconnected(): utime.sleep_ms(100) timeout -= 1 if timeout == 0: break if sta.isconnected(): print('Connected', sta.ifconfig()) webrepl.start() kit.set_background([0, 10, 0]) draw_ip(sta.ifconfig()[0]) kit.render() else: print('Not connected') kit.set_background([10, 0, 0]) draw_ip() kit.render()
global render for x in render_list: kit.set_pixel(x[0], x[1], x[2]) def get_brightness(percentage): global brightness brightness = round(255 * percentage) get_colour(temp_percent) kit.on_joystick_left = go_left kit.on_joystick_right = go_right kit.on_joystick_up = go_up kit.on_joystick_down = go_down kit.on_button_a = click kit.on_button_b = toggle kit.on_joystick_click = joystick while True: percentage = get_percentage() if hue: get_colour(percentage) else: get_brightness(percentage) kit.check_controls() kit.set_background(black) render_drawing() kit.set_pixel(position_x, position_y, colour) kit.render() sleep(0.1)
def line(x1, y1, x2, y2, color): for pixel in bresenham(x1, y1, x2, y2): kit.setPixel(pixel[0], pixel[1], color) kit.render()
def render(): kit.clear() renderStage() renderPixel() renderPixelHeading() kit.render()
def cover(): kit.clear([0, 0, 0]) renderStage() kit.render()
def clearScreen(): for i in range(0, 16): for j in range(0, 8): kit.set_pixel(15 - i, j, [10, 10, 10]) kit.render() sleep(0.2)
def cover(): kit.clear() renderStage() kit.render()