def update():
    global gameOver
    if stage[shooterPosition][0] != 0:
        gameOver = True
    kit.clear()
    renderStage()
    kit.setPixel(0, shooterPosition, colors[currentColor])
    kit.render()
示例#2
0
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()
示例#3
0
def renderStage():
    global stage
    global score
    sum = 0
    for i, row in enumerate(stage):
        for j, value in enumerate(row):
            sum = sum + value
            color = [10 * value] * 3
            kit.setPixel(j, i, color)
    if sum == 0:
        score = score + 1
        restart()
示例#4
0
def renderMainShipBullets():
    for i, bullet in enumerate(mainShip.bullets):
        if t % 2 == 0:
            bullet.move()
            if bullet.life > 20:
                del mainShip.bullets[i]
            else:
                for j, enemy in enumerate(enemies):
                    if enemy.getX() == bullet.getX() and enemy.getY(
                    ) == bullet.getY():
                        del enemies[j]
                        del mainShip.bullets[i]
        kit.setPixel(bullet.getX(), bullet.getY(), colors[4])
示例#5
0
def renderEnemies():
    for enemy in enemies:
        if t % 96 == 0:
            enemy.turnRight()
        elif t % 48 == 0:
            enemy.turnLeft()
        if t % 24 == 0:
            enemy.moveForward()
        for y, row in enumerate(enemy.getSprite()):
            for x, c in enumerate(row):
                if c != 0:
                    kit.setPixel((enemy.getX() + x - 1) % 16,
                                 (enemy.getY() + y - 1) % 8,
                                 colors[(c + 2) % len(colors)])
示例#6
0
def loop():
    global t
    t = t + 1
    kit.checkControls()
    if not gameOver:
        if t % int(level) == 0:
            updateBall()
        kit.clear()
        renderFrame()
        kit.render()
    else:
        kit.setBackground([10, 10, 0])
        for i in range(0, score):
            kit.setPixel(i % 16, int(i / 16), [10, 0, 0])
        kit.render()
示例#7
0
def loop():
    if not gameOver:
        moveObstacle()
        renderObstacle()
        jump()
        checkCollision()

    renderFloor()
    renderSky()
    renderCharacter()

    if gameOver:
        for i in range(0, int(level * 2)):
            kit.setPixel(i % 16, int(i / 16), colors[4])
        if kit.isPressingB:
            reset()
示例#8
0
def renderSky():
    i = int(t / 2)
    for y, line in enumerate(sky):
        for x, pixel in enumerate(line):
            kit.setPixel(x, y, colors[sky[y][(x + i) % 16]])
示例#9
0
def renderObstacle():
    n = int(obstaclePosition)
    kit.setPixel(n, 6, colors[6])
    kit.setPixel(n, 5, colors[6])
    kit.setPixel(n + 1, 6, colors[6])
    kit.setPixel(n + 1, 5, colors[6])
示例#10
0
def line(x1, y1, x2, y2, color):
    for pixel in bresenham(x1, y1, x2, y2):
        kit.setPixel(pixel[0], pixel[1], color)
    kit.render()
示例#11
0
def renderFloor():
    for x in range(0, 16):
        kit.setPixel(x, 7, colors[5])
示例#12
0
def renderPixel():
    if pixelVisible and inStage(cursor[0], cursor[1]):
        kit.setPixel(cursor[0], cursor[1], color)
示例#13
0
def renderPixelHeading():
    vector = headings[heading]
    nx = cursor[0]+vector[0]
    ny = cursor[1]+vector[1]
    if pixelHeadingVisible and inStage(nx, ny):
        kit.setPixel(nx, ny, headingColor)
def renderStage():
    for i, row in enumerate(stage):
        for j, value in enumerate(row):
            kit.setPixel(j, i, colors[value])
示例#15
0
def renderRightPad():
    for i in range(0, padSize):
        kit.setPixel(15, int(padPosition + i), [0, 10, 0])
示例#16
0
def renderBall():
    kit.setPixel(ballPosition[0], ballPosition[1], colors[4])
def clearScreen():
    for i in range(0, 16):
        for j in range(0, 8):
            kit.setPixel(15 - i, j, [10, 10, 10])
        kit.render()
        sleep(0.2)
示例#18
0
def renderStage():
    for y, line in enumerate(stage):
        for x, pixel in enumerate(line):
            kit.setPixel(x, y, colors[pixel])
示例#19
0
def renderMainShip():
    for y, row in enumerate(mainShip.getSprite()):
        for x, c in enumerate(row):
            kit.setPixel((mainShip.getX() + x - 1) % 16,
                         (mainShip.getY() + y - 1) % 8, colors[c])
示例#20
0
def renderBall():
    kit.setPixel(ballPosition[0], ballPosition[1], [20, 20, 20])
示例#21
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.setPixel(x, ny, colors[charSprite[i][y][x]])
示例#22
0
def renderStage():
    for y, row in enumerate(stage):
        for x, col in enumerate(row):
            kit.setPixel(x, y, stage[y][x])
示例#23
0
def renderPad():
    for x in range(padPosition, padPosition+padSize):
        kit.setPixel(x, 7, colors[7])
示例#24
0
def renderLeftPad():
    for i in range(0, padSize):
        kit.setPixel(0, int(padPosition + i), [0, 0, 10])