diff --git a/V5.5/1.png b/V5.5/1.png new file mode 100644 index 0000000..893c8ff Binary files /dev/null and b/V5.5/1.png differ diff --git a/V5.5/10.png b/V5.5/10.png new file mode 100644 index 0000000..68bc23f Binary files /dev/null and b/V5.5/10.png differ diff --git a/V5.5/2.png b/V5.5/2.png new file mode 100644 index 0000000..559e110 Binary files /dev/null and b/V5.5/2.png differ diff --git a/V5.5/3.png b/V5.5/3.png new file mode 100644 index 0000000..185a188 Binary files /dev/null and b/V5.5/3.png differ diff --git a/V5.5/4.png b/V5.5/4.png new file mode 100644 index 0000000..c345ebc Binary files /dev/null and b/V5.5/4.png differ diff --git a/V5.5/5.png b/V5.5/5.png new file mode 100644 index 0000000..a510511 Binary files /dev/null and b/V5.5/5.png differ diff --git a/V5.5/6.png b/V5.5/6.png new file mode 100644 index 0000000..a8d4b93 Binary files /dev/null and b/V5.5/6.png differ diff --git a/V5.5/7.png b/V5.5/7.png new file mode 100644 index 0000000..0b8640d Binary files /dev/null and b/V5.5/7.png differ diff --git a/V5.5/8.png b/V5.5/8.png new file mode 100644 index 0000000..9904e80 Binary files /dev/null and b/V5.5/8.png differ diff --git a/V5.5/9.png b/V5.5/9.png new file mode 100644 index 0000000..7d13cf3 Binary files /dev/null and b/V5.5/9.png differ diff --git a/V5.5/balle.png b/V5.5/balle.png new file mode 100644 index 0000000..e1f3d1b Binary files /dev/null and b/V5.5/balle.png differ diff --git a/V5.5/coeur.png b/V5.5/coeur.png new file mode 100644 index 0000000..314e286 Binary files /dev/null and b/V5.5/coeur.png differ diff --git a/V5.5/coeurfaded.png b/V5.5/coeurfaded.png new file mode 100644 index 0000000..e6d4def Binary files /dev/null and b/V5.5/coeurfaded.png differ diff --git a/V5.5/joueur.png b/V5.5/joueur.png new file mode 100644 index 0000000..68bc23f Binary files /dev/null and b/V5.5/joueur.png differ diff --git a/V5.5/terrain.png b/V5.5/terrain.png new file mode 100644 index 0000000..7be2ebe Binary files /dev/null and b/V5.5/terrain.png differ diff --git a/V5.6/1.png b/V5.6/1.png new file mode 100644 index 0000000..893c8ff Binary files /dev/null and b/V5.6/1.png differ diff --git a/V5.6/10.png b/V5.6/10.png new file mode 100644 index 0000000..68bc23f Binary files /dev/null and b/V5.6/10.png differ diff --git a/V5.6/2.png b/V5.6/2.png new file mode 100644 index 0000000..559e110 Binary files /dev/null and b/V5.6/2.png differ diff --git a/V5.6/3.png b/V5.6/3.png new file mode 100644 index 0000000..185a188 Binary files /dev/null and b/V5.6/3.png differ diff --git a/V5.6/4.png b/V5.6/4.png new file mode 100644 index 0000000..c345ebc Binary files /dev/null and b/V5.6/4.png differ diff --git a/V5.6/5.png b/V5.6/5.png new file mode 100644 index 0000000..a510511 Binary files /dev/null and b/V5.6/5.png differ diff --git a/V5.6/6.png b/V5.6/6.png new file mode 100644 index 0000000..a8d4b93 Binary files /dev/null and b/V5.6/6.png differ diff --git a/V5.6/7.png b/V5.6/7.png new file mode 100644 index 0000000..0b8640d Binary files /dev/null and b/V5.6/7.png differ diff --git a/V5.6/8.png b/V5.6/8.png new file mode 100644 index 0000000..9904e80 Binary files /dev/null and b/V5.6/8.png differ diff --git a/V5.6/9.png b/V5.6/9.png new file mode 100644 index 0000000..7d13cf3 Binary files /dev/null and b/V5.6/9.png differ diff --git a/V5.6/balle.png b/V5.6/balle.png new file mode 100644 index 0000000..e1f3d1b Binary files /dev/null and b/V5.6/balle.png differ diff --git a/V5.6/besoindemusiques.py b/V5.6/besoindemusiques.py new file mode 100644 index 0000000..ef3b421 --- /dev/null +++ b/V5.6/besoindemusiques.py @@ -0,0 +1,37 @@ +# import os +# from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip + +# video_file = "playlist for silly goofsters.webm" + +# timestamps = [ +# ("0:00", "4:15", "pineapple_rag_techno_remake"), +# ("4:15", "5:40", "scheming_weasel"), +# ("5:40", "7:12", "kk_parade"), +# ("7:12", "7:34", "spooktune"), +# ("7:34", "9:15", "dokeshi_no_koshin"), +# ("9:15", "15:12", "jades_theme"), +# ("15:12", "16:47", "spazzmatica_polka"), +# ("16:47", "19:22", "14_crush"), +# ("19:22", "20:03", "tem_shop"), +# ("20:03", "22:13", "drinky_bird"), +# ("22:13", "23:26", "aquatic_race"), +# ("23:26", "26:45", "pixel_peeker_polka"), +# ("26:45", "27:26", "vs_lancer"), +# ("27:26", "30:00", "pppp_papipupepo") +# ] + +# output_folder = "output_folder" +# os.makedirs(output_folder, exist_ok=True) + +# for i, (start_time, end_time, name) in enumerate(timestamps): +# start_seconds = sum(x * int(t) for x, t in zip([60, 1], start_time.split(":"))) +# end_seconds = sum(x * int(t) for x, t in zip([60, 1], end_time.split(":"))) +# output_file = f"{output_folder}/{i}.webm" + +# ffmpeg_extract_subclip(video_file, start_seconds, end_seconds, targetname=output_file) + + +# ffmpeg -i 6.webm -vn 6.mp3 + +for i in range (7, 14): + print('ffmpeg -i ', i,'.webm -vn ',i,'.mp3', sep='') \ No newline at end of file diff --git a/V5.6/coeur.png b/V5.6/coeur.png new file mode 100644 index 0000000..314e286 Binary files /dev/null and b/V5.6/coeur.png differ diff --git a/V5.6/coeurfaded.png b/V5.6/coeurfaded.png new file mode 100644 index 0000000..e6d4def Binary files /dev/null and b/V5.6/coeurfaded.png differ diff --git a/V5.6/joueur.png b/V5.6/joueur.png new file mode 100644 index 0000000..68bc23f Binary files /dev/null and b/V5.6/joueur.png differ diff --git a/V5.6/output_folder/all/0.webm b/V5.6/output_folder/all/0.webm new file mode 100644 index 0000000..4d66aec Binary files /dev/null and b/V5.6/output_folder/all/0.webm differ diff --git a/V5.6/output_folder/all/1.webm b/V5.6/output_folder/all/1.webm new file mode 100644 index 0000000..6474b39 Binary files /dev/null and b/V5.6/output_folder/all/1.webm differ diff --git a/V5.6/output_folder/all/10.webm b/V5.6/output_folder/all/10.webm new file mode 100644 index 0000000..b9837dd Binary files /dev/null and b/V5.6/output_folder/all/10.webm differ diff --git a/V5.6/output_folder/all/11.webm b/V5.6/output_folder/all/11.webm new file mode 100644 index 0000000..54cc852 Binary files /dev/null and b/V5.6/output_folder/all/11.webm differ diff --git a/V5.6/output_folder/all/12.webm b/V5.6/output_folder/all/12.webm new file mode 100644 index 0000000..a70410a Binary files /dev/null and b/V5.6/output_folder/all/12.webm differ diff --git a/V5.6/output_folder/all/13.webm b/V5.6/output_folder/all/13.webm new file mode 100644 index 0000000..725424e Binary files /dev/null and b/V5.6/output_folder/all/13.webm differ diff --git a/V5.6/output_folder/all/14.opus b/V5.6/output_folder/all/14.opus new file mode 100644 index 0000000..8d25b9e Binary files /dev/null and b/V5.6/output_folder/all/14.opus differ diff --git a/V5.6/output_folder/all/15.m4a b/V5.6/output_folder/all/15.m4a new file mode 100644 index 0000000..069d500 Binary files /dev/null and b/V5.6/output_folder/all/15.m4a differ diff --git a/V5.6/output_folder/all/16.opus b/V5.6/output_folder/all/16.opus new file mode 100644 index 0000000..5237b76 Binary files /dev/null and b/V5.6/output_folder/all/16.opus differ diff --git a/V5.6/output_folder/all/2.webm b/V5.6/output_folder/all/2.webm new file mode 100644 index 0000000..9fcd739 Binary files /dev/null and b/V5.6/output_folder/all/2.webm differ diff --git a/V5.6/output_folder/all/3.webm b/V5.6/output_folder/all/3.webm new file mode 100644 index 0000000..a2b572d Binary files /dev/null and b/V5.6/output_folder/all/3.webm differ diff --git a/V5.6/output_folder/all/4.webm b/V5.6/output_folder/all/4.webm new file mode 100644 index 0000000..97985cc Binary files /dev/null and b/V5.6/output_folder/all/4.webm differ diff --git a/V5.6/output_folder/all/5.webm b/V5.6/output_folder/all/5.webm new file mode 100644 index 0000000..612a5bd Binary files /dev/null and b/V5.6/output_folder/all/5.webm differ diff --git a/V5.6/output_folder/all/6.webm b/V5.6/output_folder/all/6.webm new file mode 100644 index 0000000..7189da9 Binary files /dev/null and b/V5.6/output_folder/all/6.webm differ diff --git a/V5.6/output_folder/all/7.webm b/V5.6/output_folder/all/7.webm new file mode 100644 index 0000000..b48e381 Binary files /dev/null and b/V5.6/output_folder/all/7.webm differ diff --git a/V5.6/output_folder/all/8.webm b/V5.6/output_folder/all/8.webm new file mode 100644 index 0000000..e0b4a1b Binary files /dev/null and b/V5.6/output_folder/all/8.webm differ diff --git a/V5.6/output_folder/all/9.webm b/V5.6/output_folder/all/9.webm new file mode 100644 index 0000000..d68e7ab Binary files /dev/null and b/V5.6/output_folder/all/9.webm differ diff --git a/V5.6/output_folder/fusion.bat b/V5.6/output_folder/fusion.bat new file mode 100644 index 0000000..579e62b --- /dev/null +++ b/V5.6/output_folder/fusion.bat @@ -0,0 +1,4 @@ +cd C:\Users\Noham\Documents\GitHub\Projet-foot\V5.6\output_folder +ffmpeg -i 14.opus -vn 14.mp3 +ffmpeg -i 15.m4A -vn 15.mp3 +ffmpeg -i 16.opus -vn 16.mp3 \ No newline at end of file diff --git a/V5.6/output_folder/mp3/0.mp3 b/V5.6/output_folder/mp3/0.mp3 new file mode 100644 index 0000000..e91bcd7 Binary files /dev/null and b/V5.6/output_folder/mp3/0.mp3 differ diff --git a/V5.6/output_folder/mp3/1.mp3 b/V5.6/output_folder/mp3/1.mp3 new file mode 100644 index 0000000..758e420 Binary files /dev/null and b/V5.6/output_folder/mp3/1.mp3 differ diff --git a/V5.6/output_folder/mp3/10.mp3 b/V5.6/output_folder/mp3/10.mp3 new file mode 100644 index 0000000..4725838 Binary files /dev/null and b/V5.6/output_folder/mp3/10.mp3 differ diff --git a/V5.6/output_folder/mp3/11.mp3 b/V5.6/output_folder/mp3/11.mp3 new file mode 100644 index 0000000..326ebc1 Binary files /dev/null and b/V5.6/output_folder/mp3/11.mp3 differ diff --git a/V5.6/output_folder/mp3/12.mp3 b/V5.6/output_folder/mp3/12.mp3 new file mode 100644 index 0000000..a6d73bf Binary files /dev/null and b/V5.6/output_folder/mp3/12.mp3 differ diff --git a/V5.6/output_folder/mp3/13.mp3 b/V5.6/output_folder/mp3/13.mp3 new file mode 100644 index 0000000..a8149b9 Binary files /dev/null and b/V5.6/output_folder/mp3/13.mp3 differ diff --git a/V5.6/output_folder/mp3/14.mp3 b/V5.6/output_folder/mp3/14.mp3 new file mode 100644 index 0000000..d690125 Binary files /dev/null and b/V5.6/output_folder/mp3/14.mp3 differ diff --git a/V5.6/output_folder/mp3/15.mp3 b/V5.6/output_folder/mp3/15.mp3 new file mode 100644 index 0000000..2311755 Binary files /dev/null and b/V5.6/output_folder/mp3/15.mp3 differ diff --git a/V5.6/output_folder/mp3/16.mp3 b/V5.6/output_folder/mp3/16.mp3 new file mode 100644 index 0000000..90d466c Binary files /dev/null and b/V5.6/output_folder/mp3/16.mp3 differ diff --git a/V5.6/output_folder/mp3/2.mp3 b/V5.6/output_folder/mp3/2.mp3 new file mode 100644 index 0000000..0b5d0a6 Binary files /dev/null and b/V5.6/output_folder/mp3/2.mp3 differ diff --git a/V5.6/output_folder/mp3/3.mp3 b/V5.6/output_folder/mp3/3.mp3 new file mode 100644 index 0000000..3812919 Binary files /dev/null and b/V5.6/output_folder/mp3/3.mp3 differ diff --git a/V5.6/output_folder/mp3/4.mp3 b/V5.6/output_folder/mp3/4.mp3 new file mode 100644 index 0000000..7e7ac81 Binary files /dev/null and b/V5.6/output_folder/mp3/4.mp3 differ diff --git a/V5.6/output_folder/mp3/5.mp3 b/V5.6/output_folder/mp3/5.mp3 new file mode 100644 index 0000000..b0312eb Binary files /dev/null and b/V5.6/output_folder/mp3/5.mp3 differ diff --git a/V5.6/output_folder/mp3/6.mp3 b/V5.6/output_folder/mp3/6.mp3 new file mode 100644 index 0000000..623c312 Binary files /dev/null and b/V5.6/output_folder/mp3/6.mp3 differ diff --git a/V5.6/output_folder/mp3/7.mp3 b/V5.6/output_folder/mp3/7.mp3 new file mode 100644 index 0000000..a08f0b6 Binary files /dev/null and b/V5.6/output_folder/mp3/7.mp3 differ diff --git a/V5.6/output_folder/mp3/8.mp3 b/V5.6/output_folder/mp3/8.mp3 new file mode 100644 index 0000000..e08e717 Binary files /dev/null and b/V5.6/output_folder/mp3/8.mp3 differ diff --git a/V5.6/output_folder/mp3/9.mp3 b/V5.6/output_folder/mp3/9.mp3 new file mode 100644 index 0000000..06da86b Binary files /dev/null and b/V5.6/output_folder/mp3/9.mp3 differ diff --git a/V5.6/playlist for silly goofsters.webm b/V5.6/playlist for silly goofsters.webm new file mode 100644 index 0000000..c5b9f6d Binary files /dev/null and b/V5.6/playlist for silly goofsters.webm differ diff --git a/V5.6/terrain.png b/V5.6/terrain.png new file mode 100644 index 0000000..7be2ebe Binary files /dev/null and b/V5.6/terrain.png differ diff --git a/flemmedetaper.py b/flemmedetaper.py new file mode 100644 index 0000000..efdf9a0 --- /dev/null +++ b/flemmedetaper.py @@ -0,0 +1,28 @@ +# player_image = pygame.image.load("V5/joueur.png") +# player_image = pygame.transform.scale(pygame.image.load("V5/joueur.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) # Au cas où l'image fait pas la bonne taille + +# for i in range (1,11): +# print('sprite_image_', i, ' = pygame.transform.scale(pygame.image.load("V5.5/', i, '.png"), (SPRITE_WIDTH, SPRITE_HEIGHT))', sep='') + + +SPRITE_WIDTH = 100 # Largeur d'un sprite +SPRITE_HEIGHT = 100 # Hauteur d'un sprite +SPACING_X = 20 # Espacement horizontal entre les sprites +SPACING_Y = 20 # Espacement vertical entre les lignes de sprites +SCREEN_WIDTH = 800 # Largeur de l'écran +SCREEN_HEIGHT = 600 # Hauteur de l'écran + +# Calculer les coordonnées de position des sprites +start_x = (SCREEN_WIDTH - (SPRITE_WIDTH * 5 + SPACING_X * 4)) // 2 +start_y = (SCREEN_HEIGHT - (SPRITE_HEIGHT * 2 + SPACING_Y)) // 2 +listex = [] +listey = [] +for row in range(2): + for col in range(5): + x = start_x + col * (SPRITE_WIDTH + SPACING_X) + y = start_y + row * (SPRITE_HEIGHT + SPACING_Y) + listex.append(x) + listey.append(y) + +print('listex = ', listex, sep='') +print('listey = ' , listey, sep='') \ No newline at end of file diff --git a/jeu V5.5.py b/jeu V5.5.py new file mode 100644 index 0000000..1d3197d --- /dev/null +++ b/jeu V5.5.py @@ -0,0 +1,255 @@ +import pygame +import random +import sys +from pygame.locals import * + +pygame.init() + +# Paramètres de l'écran +WIDTH = 800 +HEIGHT = 600 + +# Paramètres de couleurs +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +GRIS = (111, 111, 111) # pas sûr de la valeur mdrr + +# Paramètres de la balle +BALL_WIDTH = 50 +BALL_HEIGHT = 50 +BALL_RADIUS = 50//2 + +# Paramètres du joueur +PLAYER_WIDTH = 80 +PLAYER_HEIGHT = 80 + +# Paramètres des sprites +SPRITE_WIDTH = 80 +SPRITE_HEIGHT = 80 + +# Paramètres du coeur +COEUR_WIDTH = 75 +COEUR_HEIGHT = COEUR_WIDTH*(440/512) +nbcoeur = 1 + +# Images choisies +player_image = pygame.transform.scale(pygame.image.load("V5/joueur.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) # Au cas où l'image fait pas la bonne taille + +ball_image = pygame.transform.scale(pygame.image.load("V5/balle.png"), (BALL_WIDTH, BALL_HEIGHT)) + +coeur_image = pygame.transform.scale(pygame.image.load("V5/coeur.png"), (COEUR_WIDTH, COEUR_HEIGHT)) +coeurfaded_image = pygame.transform.scale(pygame.image.load("V5/coeurfaded.png"), (COEUR_WIDTH, COEUR_HEIGHT)) + +background_image = pygame.transform.scale(pygame.image.load("V5/terrain.png"), (WIDTH, HEIGHT)) + + +listex = [110, 230, 350, 470, 590, 110, 230, 350, 470, 590] +listey = [190, 190, 190, 190, 190, 310, 310, 310, 310, 310] + +sprites = [] # Liste pour stocker les sprites +sprite_rects = [] # Liste pour stocker les rectangles englobants des sprites +selected_sprite = None # Le sprite choisi + +# Charger les 10 sprites +for i in range(10): + sprite_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (SPRITE_WIDTH, SPRITE_HEIGHT)) + sprites.append(sprite_image) + sprite_rect = sprite_image.get_rect() + sprite_rect.topleft = (listex[i], listey[i]) # Définir les coordonnées du sprite + sprite_rects.append(sprite_rect) + +# Définir les dimensions et la position du rectangle pour le score +largeur_rectangle = 150 +hauteur_rectangle = 40 +x_rectangle = (WIDTH - largeur_rectangle) // 2 # Au milieu horizontalement +y_rectangle = 0 # En haut de l'écran + +# Variables du jeu +score = 0 +font = pygame.font.Font(None, 36) +dercolsol = 0 +nbrotation = 0 + +# Initialisation de l'écran de jeu +screen = pygame.display.set_mode((WIDTH, HEIGHT)) +pygame.display.set_caption("Jeu V5.5") + + +def start_screen(): + selected_sprite = None + screen.fill(BLACK) + start_text = font.render("Appuyez sur une touche pour commencer", True, WHITE) + start_text_rect = start_text.get_rect() + start_text_rect.centerx = WIDTH // 2 + start_text_rect.centery = HEIGHT // 5 + screen.blit(start_text, start_text_rect) + for i, sprite in enumerate(sprites): + screen.blit(sprite, sprite_rects[i]) + pygame.display.flip() + + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + return selected_sprite + + elif event.type == MOUSEBUTTONDOWN and event.button == 1: # Clic gauche de la souris + print("L'utilisateur a cliqué") + mouse_pos = pygame.mouse.get_pos() + + if start_text_rect.collidepoint(mouse_pos): + print("L'utilisateur a cliqué sur le texte de départ.") + + for i, sprite_rect in enumerate(sprite_rects): + if sprite_rect.collidepoint(mouse_pos): + print(f"L'utilisateur a cliqué sur le sprite {i+1}.") + selected_sprite = i + + screen.fill(BLACK) # Effacer l'écran + screen.blit(start_text, start_text_rect) + + # Dessiner les sprites à l'écran + for i, sprite in enumerate(sprites): + screen.blit(sprite, sprite_rects[i]) + + # Dessiner le rectangle autour du sprite sélectionné + if selected_sprite is not None and selected_sprite == i: + pygame.draw.rect(screen, GRIS, sprite_rects[i], 2) + + pygame.display.flip() + +def game(i): + global score, nbcoeur + + if i != 0: + player_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) + else: + i = 0 + player_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) + + # Position initiale de la balle + ball_pos = [WIDTH // 2, BALL_RADIUS] + ball_velocity_y = 0 + ball_velocity_x = 1 + gravity = 0.1 + + # Position initiale du joueur + player_pos = [WIDTH // 2 - PLAYER_WIDTH // 2, HEIGHT - PLAYER_HEIGHT - 60] + + nbcoeur = 1 + clock = pygame.time.Clock() + running = True + dercolsol = 0 + nbrotation = 0 + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + + # Gestion des mouvements du joueur + mouse_pos = pygame.mouse.get_pos() + player_pos[0] = mouse_pos[0] - PLAYER_WIDTH // 2 + + # Mise à jour de la logique du jeu + ball_velocity_y += gravity + ball_pos[1] += ball_velocity_y + + # Si la balle touche le joueur + if ball_pos[1] + BALL_RADIUS >= player_pos[1] and ball_pos[0] >= player_pos[0] and ball_pos[0] <= player_pos[0] + PLAYER_WIDTH: + ball_pos[1] = player_pos[1] - BALL_RADIUS + ball_velocity_y = -ball_velocity_y + score += 1 + ball_velocity_x += random.uniform(-3, 3) + print("Score :", score) + nbrotation+=5 + + # Si la balle touche le sol + if ball_pos[1] + BALL_RADIUS >= HEIGHT: + current_time = pygame.time.get_ticks() + if current_time - dercolsol >= 1000 : + if nbcoeur >= 1: + nbcoeur -= 1 # Décrémenter le nombre de vies + dercolsol = current_time + ball_velocity_y = -ball_velocity_y + nbrotation+=5 + + + else: + print(nbcoeur) + return False + pass + + if current_time - dercolsol <= 1000: + print(nbcoeur) + + else: + nbcoeur = nbcoeur + print(nbcoeur) + + # Si la balle touche le plafond + elif ball_pos[1] <= BALL_RADIUS: + ball_pos[1] = BALL_RADIUS + ball_velocity_y = -ball_velocity_y + nbrotation+=5 + + ball_pos[0] += ball_velocity_x + + # Si la balle touche les murs + if ball_pos[0] <= BALL_RADIUS or ball_pos[0]+BALL_RADIUS//2 >= WIDTH: + ball_velocity_x = -ball_velocity_x + nbrotation+=5 + + # Dessiner les éléments + screen.blit(background_image, (0, 0)) # Le terrain + + nbrotation+=1 + screen.blit(pygame.transform.rotate(ball_image, nbrotation), (ball_pos[0] - BALL_RADIUS, ball_pos[1] - BALL_RADIUS)) # La balle + + screen.blit(player_image, (player_pos[0], player_pos[1])) # Le joueur + + # Afficher le nombre de coeur(s) + if nbcoeur == 1 : + screen.blit(coeur_image, (25, 25)) # Le coeur + + if nbcoeur == 0: + screen.blit(coeurfaded_image, (25,25)) # Le coeur plus transparent + + # Afficher le score + pygame.draw.rect(screen, BLACK, (x_rectangle, y_rectangle, largeur_rectangle, hauteur_rectangle)) + + text = font.render("Score : " + str(score), True, WHITE) + text_rect = text.get_rect() + text_rect.center = (WIDTH // 2, 20) + screen.blit(text, text_rect) # Le score + + #_____________ Ne rien mettre en dessous _____________ + pygame.display.flip() + clock.tick(60) + +def game_over_screen(): + screen.fill(BLACK) + perdu_text = font.render("Perdu", True, WHITE) + perdu_text_rect = perdu_text.get_rect() + perdu_text_rect.centerx = WIDTH // 2 + perdu_text_rect.centery = HEIGHT // 2 + screen.blit(perdu_text, perdu_text_rect) + pygame.display.flip() + pygame.time.wait(3000) + +# Boucle principale +running = True +while running: + selected_sprite = None + selected_skin = start_screen() + print('le skin choisi est :', selected_skin) + score = 0 + nbcoeur = 1 + dercolsol = 0 + nbrotation = 0 + game_over = game(selected_skin) + print(game_over) + if game_over == False: + game_over_screen() + running = False + +pygame.quit() diff --git a/jeu V5.6.py b/jeu V5.6.py new file mode 100644 index 0000000..6892991 --- /dev/null +++ b/jeu V5.6.py @@ -0,0 +1,264 @@ +import pygame +import random +import sys +from pygame.locals import * + +pygame.init() + +# Paramètres de l'écran +WIDTH = 800 +HEIGHT = 600 + +# Paramètres de couleurs +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +GRIS = (111, 111, 111) # pas sûr de la valeur mdrr + +# Paramètres de la balle +BALL_WIDTH = 50 +BALL_HEIGHT = 50 +BALL_RADIUS = 50//2 + +# Paramètres du joueur +PLAYER_WIDTH = 80 +PLAYER_HEIGHT = 80 + +# Paramètres des sprites +SPRITE_WIDTH = 80 +SPRITE_HEIGHT = 80 + +# Paramètres du coeur +COEUR_WIDTH = 75 +COEUR_HEIGHT = COEUR_WIDTH*(440/512) +nbcoeur = 1 + +# Images choisies +player_image = pygame.transform.scale(pygame.image.load("V5/joueur.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) # Au cas où l'image fait pas la bonne taille + +ball_image = pygame.transform.scale(pygame.image.load("V5/balle.png"), (BALL_WIDTH, BALL_HEIGHT)) + +coeur_image = pygame.transform.scale(pygame.image.load("V5/coeur.png"), (COEUR_WIDTH, COEUR_HEIGHT)) +coeurfaded_image = pygame.transform.scale(pygame.image.load("V5/coeurfaded.png"), (COEUR_WIDTH, COEUR_HEIGHT)) + +background_image = pygame.transform.scale(pygame.image.load("V5/terrain.png"), (WIDTH, HEIGHT)) + + +listex = [110, 230, 350, 470, 590, 110, 230, 350, 470, 590] +listey = [190, 190, 190, 190, 190, 310, 310, 310, 310, 310] + +sprites = [] # Liste pour stocker les sprites +sprite_rects = [] # Liste pour stocker les rectangles englobants des sprites +selected_sprite = None # Le sprite choisi + +# Charger les 10 sprites +for i in range(10): + sprite_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (SPRITE_WIDTH, SPRITE_HEIGHT)) + sprites.append(sprite_image) + sprite_rect = sprite_image.get_rect() + sprite_rect.topleft = (listex[i], listey[i]) # Définir les coordonnées du sprite + sprite_rects.append(sprite_rect) + +# Charger une musique parmis la super compilation +i = random.randint(0, 17) +path = 'V5.6/output_folder/mp3/' +musique = path + str(i) + '.mp3' +pygame.mixer.music.load(musique) + + + +# Définir les dimensions et la position du rectangle pour le score +largeur_rectangle = 150 +hauteur_rectangle = 40 +x_rectangle = (WIDTH - largeur_rectangle) // 2 # Au milieu horizontalement +y_rectangle = 0 # En haut de l'écran + +# Variables du jeu +score = 0 +font = pygame.font.Font(None, 36) +dercolsol = 0 +nbrotation = 0 + +# Initialisation de l'écran de jeu +screen = pygame.display.set_mode((WIDTH, HEIGHT)) +pygame.display.set_caption("Jeu V5.5") + + +def start_screen(): + selected_sprite = None + screen.fill(BLACK) + start_text = font.render("Appuyez sur une touche pour commencer", True, WHITE) + start_text_rect = start_text.get_rect() + start_text_rect.centerx = WIDTH // 2 + start_text_rect.centery = HEIGHT // 5 + screen.blit(start_text, start_text_rect) + for i, sprite in enumerate(sprites): + screen.blit(sprite, sprite_rects[i]) + pygame.display.flip() + + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + return selected_sprite + + elif event.type == MOUSEBUTTONDOWN and event.button == 1: # Clic gauche de la souris + print("L'utilisateur a cliqué") + mouse_pos = pygame.mouse.get_pos() + + if start_text_rect.collidepoint(mouse_pos): + print("L'utilisateur a cliqué sur le texte de départ.") + + for i, sprite_rect in enumerate(sprite_rects): + if sprite_rect.collidepoint(mouse_pos): + print(f"L'utilisateur a cliqué sur le sprite {i+1}.") + selected_sprite = i + + screen.fill(BLACK) # Effacer l'écran + screen.blit(start_text, start_text_rect) + + # Dessiner les sprites à l'écran + for i, sprite in enumerate(sprites): + screen.blit(sprite, sprite_rects[i]) + + # Dessiner le rectangle autour du sprite sélectionné + if selected_sprite is not None and selected_sprite == i: + pygame.draw.rect(screen, GRIS, sprite_rects[i], 2) + + pygame.display.flip() + +def game(i): + global score, nbcoeur + + if i != 0: + player_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) + else: + i = 0 + player_image = pygame.transform.scale(pygame.image.load(f"V5.5/{i+1}.png"), (PLAYER_WIDTH, PLAYER_HEIGHT)) + + # Position initiale de la balle + ball_pos = [WIDTH // 2, BALL_RADIUS] + ball_velocity_y = 0 + ball_velocity_x = 1 + gravity = 0.1 + + # Position initiale du joueur + player_pos = [WIDTH // 2 - PLAYER_WIDTH // 2, HEIGHT - PLAYER_HEIGHT - 60] + + nbcoeur = 1 + clock = pygame.time.Clock() + running = True + dercolsol = 0 + nbrotation = 0 + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + + # Gestion des mouvements du joueur + mouse_pos = pygame.mouse.get_pos() + player_pos[0] = mouse_pos[0] - PLAYER_WIDTH // 2 + + # Mise à jour de la logique du jeu + ball_velocity_y += gravity + ball_pos[1] += ball_velocity_y + + # Si la balle touche le joueur + if ball_pos[1] + BALL_RADIUS >= player_pos[1] and ball_pos[0] >= player_pos[0] and ball_pos[0] <= player_pos[0] + PLAYER_WIDTH: + ball_pos[1] = player_pos[1] - BALL_RADIUS + ball_velocity_y = -ball_velocity_y + score += 1 + ball_velocity_x += random.uniform(-3, 3) + print("Score :", score) + nbrotation+=5 + + # Si la balle touche le sol + if ball_pos[1] + BALL_RADIUS >= HEIGHT: + current_time = pygame.time.get_ticks() + if current_time - dercolsol >= 1000 : + if nbcoeur >= 1: + nbcoeur -= 1 # Décrémenter le nombre de vies + dercolsol = current_time + ball_velocity_y = -ball_velocity_y + nbrotation+=5 + + + else: + print(nbcoeur) + return False + pass + + if current_time - dercolsol <= 1000: + print(nbcoeur) + + else: + nbcoeur = nbcoeur + print(nbcoeur) + + # Si la balle touche le plafond + elif ball_pos[1] <= BALL_RADIUS: + ball_pos[1] = BALL_RADIUS + ball_velocity_y = -ball_velocity_y + nbrotation+=5 + + ball_pos[0] += ball_velocity_x + + # Si la balle touche les murs + if ball_pos[0] <= BALL_RADIUS or ball_pos[0]+BALL_RADIUS//2 >= WIDTH: + ball_velocity_x = -ball_velocity_x + nbrotation+=5 + + # Dessiner les éléments + screen.blit(background_image, (0, 0)) # Le terrain + + nbrotation+=1 + screen.blit(pygame.transform.rotate(ball_image, nbrotation), (ball_pos[0] - BALL_RADIUS, ball_pos[1] - BALL_RADIUS)) # La balle + + screen.blit(player_image, (player_pos[0], player_pos[1])) # Le joueur + + # Afficher le nombre de coeur(s) + if nbcoeur == 1 : + screen.blit(coeur_image, (25, 25)) # Le coeur + + if nbcoeur == 0: + screen.blit(coeurfaded_image, (25,25)) # Le coeur plus transparent + + # Afficher le score + pygame.draw.rect(screen, BLACK, (x_rectangle, y_rectangle, largeur_rectangle, hauteur_rectangle)) + + text = font.render("Score : " + str(score), True, WHITE) + text_rect = text.get_rect() + text_rect.center = (WIDTH // 2, 20) + screen.blit(text, text_rect) # Le score + + #_____________ Ne rien mettre en dessous _____________ + pygame.display.flip() + clock.tick(60) + +def game_over_screen(): + screen.fill(BLACK) + perdu_text = font.render("Perdu", True, WHITE) + perdu_text_rect = perdu_text.get_rect() + perdu_text_rect.centerx = WIDTH // 2 + perdu_text_rect.centery = HEIGHT // 2 + screen.blit(perdu_text, perdu_text_rect) + pygame.display.flip() + pygame.time.wait(3000) + +# Boucle principale +running = True +while running: + pygame.mixer.music.play() + selected_sprite = None + selected_skin = start_screen() + print('le skin choisi est :', selected_skin) + score = 0 + nbcoeur = 1 + dercolsol = 0 + nbrotation = 0 + game_over = game(selected_skin) + print(game_over) + if game_over == False: + game_over_screen() + running = False + +pygame.quit()