Пример #1
0
def drawBombe(bombe):
    if bombe.timeActive > 0 :
        if bombe.timeActive % 5 == 0:
            display.setColor(COLOR_BOMBE)
        else : 
            display.setColor(COLOR_BOMBE_ALT)
        halfElement = (ELEMENT_COTE//2)
        display.fillCircle(bombe.posX+halfElement, bombe.posY+halfElement, halfElement)
Пример #2
0
def drawsnake():
    display.setColor(COLOR_SNAKE)
    n = snake['len']
    for i in range(n):
        x = snake['x'][i]
        y = snake['y'][i]
        display.fillRect(OX + x * SNAKE_SIZE, OY + y * SNAKE_SIZE, SNAKE_SIZE,
                         SNAKE_SIZE)
Пример #3
0
def draw():
    display.clear(COLOR_BG)
    for player in players:
        drawPlayer(player)

    for lineIndex in range(len(map)):
        for colIndex in range(len(map[lineIndex])):
            if map[lineIndex][colIndex] == MAP_WALL_BREAKABLE:
                display.setColor(COLOR_WALL)
                display.fillRect(colIndex * ELEMENT_COTE, lineIndex * ELEMENT_COTE, ELEMENT_COTE, ELEMENT_COTE)
            elif map[lineIndex][colIndex] == MAP_WALL_UNBREAKABLE:
                display.setColor(COLOR_WALL_2)
                display.fillRect(colIndex * ELEMENT_COTE, lineIndex * ELEMENT_COTE, ELEMENT_COTE, ELEMENT_COTE)
    
    for bombe in bombes:
        drawBombe(bombe)
    for flame in flames:
        drawFlame(flame)
Пример #4
0
        total = total + 1

    # Vérifier si la balle est sortie de l'écran
    if ball_x_position <= 0:
        score = 0  # Nous remettons le score à 0
        ball_x_speed = -ball_x_speed

    # Empêcher la raquette de sortir de l'écran
    if player_y_position <= 0:
        player_y_position = 0

    if player_y_position >= 64 - player_height:
        player_y_position = 64 - player_height

    # Affichage de la balle
    display.setColor(color.PINK)
    display.fillRect(ball_x_position, ball_y_position, ball_size, ball_size)

    # Affichage de la raquette du joueur
    display.setColor(color.BROWN)
    display.fillRect(player_x_position, player_y_position, player_width,
                     player_height)

    # Affichage du score
    display.setColor(color.GREEN)
    display.print("Mon score est ")
    display.print(score)

    display.print("\n")

    display.setColor(color.BLUE)
Пример #5
0
        ball_x_speed = -ball_x_speed

    # Increase the score and change the ball's direction if the ball touches the player
    if collide.rectRect(ball_x_position, ball_y_position, ball_size, ball_size,
                        player_x_position, player_y_position, player_width,
                        player_height):
        ball_x_position = ball_x_position - ball_x_speed
        ball_x_speed = -ball_x_speed
        score = score + 1

    # Reset the score if the ball touches the left border of the screen
    if ball_x_position <= 0:
        score = 0
        ball_x_speed = -ball_x_speed

    # Display ball
    display.fillRect(ball_x_position, ball_y_position, ball_size, ball_size)

    # Display player
    display.fillRect(player_x_position, player_y_position, player_width,
                     player_height)

    # Display Score
    display.setColor(color.BROWN)
    display.print("SCORE: ")
    display.print(score)
    display.print("\n")

    if score == 0:
        display.setColor(color.WHITE)
        display.print("GAME OVER!")
Пример #6
0
def drawFlame(flame):
    display.setColor(COLOR_FLAME)
    display.fillRect(flame.posX, flame.posY, ELEMENT_COTE, ELEMENT_COTE)
Пример #7
0
def drawPlayer(player):
    display.setColor(COLOR_PLAYER1)
    display.fillRect(player.posX, player.posY, ELEMENT_COTE, ELEMENT_COTE)
Пример #8
0
def draw():
    display.clear(COLOR_BG)
    display.setColor(COLOR_WALL)
    display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
Пример #9
0
from gamebuino_meta import begin, waitForUpdate, display, buttons, color

while True:
    waitForUpdate()
    display.clear()

    name = "Brian"
    score = 15
    lives = 3

    display.setColor(color.BLUE)
    display.print(name)

    display.setColor(color.GREEN)
    display.print(" (vies : ")
    display.setColor(color.RED)
    display.print(lives)
    display.setColor(color.GREEN)
    display.print(")")

    display.print("\n")
    display.print("\n")

    display.setColor(color.WHITE)
    display.print("Score : ")
    display.print(score)

    display.print("\n")
    display.print("\n")

    lives = 2
Пример #10
0
def drawwalls():
    display.setColor(COLOR_WALL)
    display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
Пример #11
0
        total = total + 1

# Vérifier si la balle est sortie de l'écran
    if BALL_X_POSITION <= 0:
        score = 0  # Nous remettons le score à 0
        BALL_X_SPEED = -BALL_X_SPEED

# Empêcher la raquette de sortir de l'écran
    if PLAYER_Y_POSITION <= 0:
        PLAYER_Y_POSITION = 0

    if PLAYER_Y_POSITION >= 64 - PLAYER_HEIGHT:
        PLAYER_Y_POSITION = 64 - PLAYER_HEIGHT

# Affichage de la balle
    display.setColor(color.ORANGE)
    display.fillRect(BALL_X_POSITION, BALL_Y_POSITION, BALL_SIZE, BALL_SIZE)

    # Affichage de la raquette du joueur
    display.setColor(color.RED)
    display.fillRect(PLAYER_X_POSTION, PLAYER_Y_POSITION, PLAYER_WIDTH,
                     PLAYER_HEIGHT)

    # Affichage du score
    display.setColor(color.GREEN)
    display.print("Mon score est ")
    display.print(score)

    display.print("\n")

    display.setColor(color.BLUE)