def update():
    global gameOver
    if stage[shooterPosition][0] != 0:
        gameOver = True
    kit.clear()
    renderStage()
    kit.set_pixel(0, shooterPosition, colors[currentColor])
    kit.render()
Example #2
0
def loop():
    if not gameOver:
        moveObstacle()
        renderObstacle()
        jump()
        checkCollision()
    renderFloor()
    renderSky()
    renderCharacter()
    if gameOver:
        for i in range(0, int(level * 2)):
            kit.set_pixel(i % 16, int(i / 16), colors[4])
        if kit.is_pressing_b:
            reset()
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()
Example #4
0
def draw_ip(ip_str='0.0.0.0', bg=[0, 0, 0], color=[10, 0, 0]):
    ip_bin = []
    for i in ip_str.split('.'):
      ip_bin.append(bin(int(i))[2:])
    output = []
    for ip in ip_bin:
      o = []
      for i in range(1, 9):
        try:
          o.insert(0, ip[-i])
        except Exception as e:
          o.insert(0, '0')
      output.append(o)
    for y, line in enumerate(output):
      for x, pixel in enumerate(line):
        if pixel == '1':
          kit.set_pixel(4+x, 2+y, color)
        else:
          kit.set_pixel(4+x, 2+y, bg)
Example #5
0
def renderFloor():
    for x in range(0, 16):
        kit.set_pixel(x, 7, colors[5])
Example #6
0
def renderStage():
    for y, line in enumerate(stage):
        for x, pixel in enumerate(line):
            kit.set_pixel(x, y, colors[pixel])
Example #7
0
import os
import machine


def reset():
    machine.reset()


def ls(path=''):
    for f in os.listdir(path):
        print(f)


if not sta.active() and ap.active():
    ip = ap.ifconfig()[0]
# CAPTIVE PORTAL
    # MicroDNSSrv.Create({ '*' : ip })
elif sta.active() and not ap.active():
    ip = sta.ifconfig()[0]

try:
    if srv:
        srv.Stop()
except NameError as err:
    srv = MicroWebSrv(webPath='')

srv.SetNotFoundPageUrl("http://{}/index.html".format(ip))
srv.Start()
kit.set_pixel(0, 0, [10, 10, 10])
kit.render()
Example #8
0
def renderPad():
    for x in range(padPosition, padPosition+padSize):
        kit.set_pixel(x, 7, colors[7])
Example #9
0
def renderBall():
    kit.set_pixel(ballPosition[0], ballPosition[1], colors[4])
Example #10
0
def renderCharacter():
    i = int(t / 4) % len(charSprite)
    for y, line in enumerate(charSprite):
        for x, pixel in enumerate(line):
            ny = int(charPosition) + y
            kit.set_pixel(x, ny, colors[charSprite[i][y][x]])
def renderStage():
    for i, row in enumerate(stage):
        for j, value in enumerate(row):
            kit.set_pixel(j, i, colors[value])
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)
Example #13
0
def renderObstacle():
    n = int(obstaclePosition)
    kit.set_pixel(n, 6, colors[6])
    kit.set_pixel(n, 5, colors[6])
    kit.set_pixel(n + 1, 6, colors[6])
    kit.set_pixel(n + 1, 5, colors[6])
def renderPixelHeading():
    vector = headings[heading]
    nx = cursor[0] + vector[0]
    ny = cursor[1] + vector[1]
    if pixelHeadingVisible and inStage(nx, ny):
        kit.set_pixel(nx, ny, headingColor)
Example #15
0
    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 renderPixel():
    if pixelVisible and inStage(cursor[0], cursor[1]):
        kit.set_pixel(cursor[0], cursor[1], color)
def renderStage():
    for y, row in enumerate(stage):
        for x, col in enumerate(row):
            kit.set_pixel(x, y, stage[y][x])
Example #18
0
def renderRightPad():
    for i in range(0, padSize):
        kit.set_pixel(15, int(padPosition + i), [0, 10, 0])
Example #19
0
def renderLeftPad():
    for i in range(0, padSize):
        kit.set_pixel(0, int(padPosition + i), [0, 0, 10])
Example #20
0
def renderBall():
    kit.set_pixel(ballPosition[0], ballPosition[1], [20, 20, 20])
Example #21
0
def render_drawing():
    global render
    for x in render_list:
        kit.set_pixel(x[0], x[1], x[2])
Example #22
0
def renderSky():
    i = int(t / 2)
    for y, line in enumerate(sky):
        for x, pixel in enumerate(line):
            kit.set_pixel(x, y, colors[sky[y][(x + i) % 16]])