def handleButtons(player): if buttons.repeat(buttons.LEFT, 0): player.nexDir = MOVE_LEFT elif buttons.repeat(buttons.RIGHT, 0): player.nexDir = MOVE_RIGHT elif buttons.repeat(buttons.UP, 0): player.nexDir = MOVE_UP elif buttons.repeat(buttons.DOWN, 0): player.nexDir = MOVE_DOWN if buttons.repeat(buttons.A, 5): initBombe(player.posX, player.posY)
# Position initiale de la raquette : player_x_position = 10 player_y_position = 30 # Score score = 0 total = 0 begin() while True: waitForUpdate() display.clear() # Si on presse les boutons UP ou DOWN, nous déplaçons la raquette vers le haut, ou vers le bas : if buttons.repeat(buttons.UP, 0): player_y_position = player_y_position - player_speed if buttons.repeat(buttons.DOWN, 0): player_y_position = player_y_position + player_speed # Nous déplaçons la balle ball_x_position = ball_x_position + ball_x_speed ball_y_position = ball_y_position + ball_y_speed # Vérification si la balle entre en collision avec le haut, bas ou droite de l'écran # Si c'est le cas, nous inversons sa direction if ball_y_position <= 0: ball_y_speed = -ball_y_speed if ball_y_position >= 64 - ball_size:
""" Writes digital output to D5 when the button A is held down Works with the modules: - Relay - LED - Buzzer """ from gamebuino_meta import waitForUpdate, display, buttons import board import digitalio myLED = digitalio.DigitalInOut(board.D5) myLED.direction = digitalio.Direction.OUTPUT while True: waitForUpdate() display.clear() display.print("DIGITAL OUTPUT\nD5: ") if buttons.repeat(buttons.A, 0): myLED.value = True display.print("ON") else: myLED.value = False display.print("OFF") display.print("\n\n'A' TO TURN ON/OFF")