def manageCommand4Mode(): try: if game['mode'] == MODE_DISPLAY_CARD and buttons.pressed(buttons.A): game['mode'] = MODE_MIX_CARD elif game['mode'] != MODE_MIX_CARD and buttons.pressed(buttons.MENU): game['mode'] = MODE_DISPLAY_NB_MIX if game['mode'] == MODE_DISPLAY_CARD else MODE_DISPLAY_CARD except: display.print('Error cmd 4 mode')
def showCards(n): try: for r in range(10): for c in range(4): if n < 52: display.print(cards[n]) display.print(' ') n += 1 display.print('\n') except: display.print('exception')
def tick(): manageCommand4Mode() try: if game['mode'] == MODE_DISPLAY_CARD: manageCommand4DisplayCards() display.clear() paint() elif game['mode'] == MODE_DISPLAY_NB_MIX: display.clear() display.print('Nb mix: ') display.print(str(game['nbMix'])) else: display.clear() display.print('Mix cards...') mixCards() resetIndexPage() game['mode'] = MODE_DISPLAY_CARD except: display.print('tick error ') display.print(str(game['mode']))
# 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 : ") display.print(total)
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!")
""" Reads Digital input from D5 and shows it on screen Works with the modules: - Switch - Tactile switch """ from gamebuino_meta import waitForUpdate, display import board import digitalio mySwitch = digitalio.DigitalInOut(board.D5) mySwitch.direction = digitalio.Direction.INPUT while True: waitForUpdate() display.clear() myValue = mySwitch.value display.print("DIGITAL INPUT\nD5: ") display.print(str(myValue)) display.print("\n\n") if myValue: display.print("ON") else: display.print("OFF")
- Potentiometer - 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)
# Ecrit ton programme ici ;-) from gamebuino_meta import begin, waitForUpdate, display, buttons, color while True: waitForUpdate() display.clear() display.print("Hello world")
""" 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")
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
""" 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)
""" from gamebuino_meta import waitForUpdate, display import board from analogio import AnalogIn import math # creates myPotentiometer that we will use to read analog input from A1 thermistor = AnalogIn(board.A1) while True: waitForUpdate() display.clear() # reads the value from the thermocouple and convert it to temperature temperature = 999.99 B = 4275.0 # B value of the thermistor R0 = 100000.0 # R0 = 100k R = 65536.0 / thermistor.value - 1.0 # analog input R = R0 * R if R / R0 > 0: temperature = 1.0 / (math.log(R / R0) / B + 1 / 298.15) - 273.15 # print it on screen display.print("TEMPERATURE SENSOR\nA1: ") display.print(thermistor.value) display.print("\nTEMP: ") display.print(str(temperature)) display.print("C")