1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| import pygame
from pygame.locals import *
pygame.init()
#Ouverture de la fenêtre Pygame
fenetre = pygame.display.set_mode((900, 650))
#Chargement des images
fond = pygame.image.load("background.jpg").convert()
fond_2 = pygame.image.load("background2.2.jpg").convert()
fond_3 = pygame.image.load("background2.jpg").convert()
niv_add = pygame.image.load("niv_add.jpg").convert()
quite = pygame.image.load("quit.png").convert_alpha()
facil = pygame.image.load("facil.png").convert_alpha()
moyen = pygame.image.load("moyen.png").convert_alpha()
mathe = pygame.image.load("math.png").convert_alpha()
add = pygame.image.load("add.png").convert_alpha()
sous = pygame.image.load("sous.png").convert_alpha()
mult = pygame.image.load("mult.png").convert_alpha()
perso = pygame.image.load("perso.png").convert_alpha()
#~ categorie accueil
def accueil():
fenetre.blit(fond, (0,0))
entrer = fenetre.blit(perso, (345,450))
quitter = fenetre.blit(quite, (823,570))
pygame.display.flip()
while True:
ev = pygame.event.wait()
if ev.type == MOUSEBUTTONDOWN and ev.button == 1:
if entrer.collidepoint(ev.pos):
return "entrer"
if quitter.collidepoint(ev.pos):
return "quitter"
def categorie():
fenetre.blit(fond_2, (0,0))
additi = fenetre.blit(add, (314,292))
soustr = fenetre.blit(sous, (314,396))
multip = fenetre.blit(mult, (314,500))
quitter = fenetre.blit(quite, (823,570))
pygame.display.flip()
while True:
ev = pygame.event.wait()
if ev.type == MOUSEBUTTONDOWN and ev.button == 1:
if additi.collidepoint(ev.pos):
return "Addition"
if quitter.collidepoint(ev.pos):
return "quitter"
def menu_niveau():
fenetre.blit(niv_add, (0,0))
facil_ = fenetre.blit(facil, (314,292))
moyen_ = fenetre.blit(moyen, (314,396))
mathe_ = fenetre.blit(mathe, (314,500))
quitter = fenetre.blit(quite, (823,570))
pygame.display.flip()
while True:
ev = pygame.event.wait()
if ev.type == MOUSEBUTTONDOWN and ev.button == 1:
if facil_.collidepoint(ev.pos):
return "Facile"
if quitter.collidepoint(ev.pos):
return "quitter"
#BOUCLE INFINIE
continuer = 1
while continuer:
if accueil() == "quitter":
break
choix_menu = categorie()
if choix_menu == "quitter":
break
choix_niveau = menu_niveau()
if choix_niveau == "quitter":
break
print(choix_menu,choix_niveau)
while pygame.event.wait().type != QUIT: continue
break
pygame.quit() |
Partager