def initialize(): display.clear() display.println("Initialize") for c in range(4): for n in range(13): card = str(n) + ',' + str(c) cards.append(card)
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)
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']))
player_width = 3 player_speed = 2 # 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:
def draw(): display.clear(COLOR_BG) display.setColor(COLOR_WALL) display.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
def clearscreen(): display.clear(COLOR_BG)