Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
0
    # 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)
    display.print("Total : ")
Esempio n. 4
0
def drawFlame(flame):
    display.setColor(COLOR_FLAME)
    display.fillRect(flame.posX, flame.posY, ELEMENT_COTE, ELEMENT_COTE)
Esempio n. 5
0
def drawPlayer(player):
    display.setColor(COLOR_PLAYER1)
    display.fillRect(player.posX, player.posY, ELEMENT_COTE, ELEMENT_COTE)
Esempio n. 6
0
- Joystick
- Light Sensor
- Loudness Sensor
- Temperature Sensor
"""

from gamebuino_meta import waitForUpdate, display
import board
from analogio import AnalogIn

# creates myPotentiometer that we will use to read analog input from A1
myPotentiometer = AnalogIn(board.A1)

while True:
    waitForUpdate()
    display.clear()

    # update your value from your potentiometer
    myValue = myPotentiometer.value

    # print it on screen
    display.print("ANALOG INPUT\nA1: ")
    display.print(myValue)

    # maps the value from 0..65536 to 0..64
    myValue = myValue * 64 // 65536

    # draw it as a rectangle
    display.drawRect(0, 16, 64, 5)
    display.fillRect(0, 16, myValue, 5)
Esempio n. 7
0
"""

from gamebuino_meta import waitForUpdate, display
import board
from analogio import AnalogIn

xAxis = AnalogIn(board.A1)
yAxis = AnalogIn(board.A2)

while True:
    waitForUpdate()
    display.clear()
    
    # reads and maps the value from 0..65536 to -range/2..range/2
    range = 40
    x = xAxis.value * range // 65536 - (range // 2)
    y = yAxis.value * range // 65536 - (range // 2)
    
    # print values
    display.print("JOYSTICK")
    display.print("\nA1 x: ")
    display.print(x)
    display.print("\nA2 y: ")
    display.print(y)
    
    # draw the graphic
    offset = 20 # vertical offset
    display.drawRect(0, 0 + offset, range, range)
    display.fillRect(0, x + range // 2 + offset, range, 1)
    display.fillRect(y + range // 2, 0 + offset, 1, range)
    
Esempio n. 8
0
# 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)
    display.print("Total : ")