|
|
@ -14,7 +14,7 @@ pygame.init() |
|
|
|
|
|
|
|
#ouverture de la fenetre |
|
|
|
fenetre = pygame.display.set_mode((largeur_fenetre, hauteur_fenetre)) |
|
|
|
fenetre.fill((0,0,0)) |
|
|
|
fenetre.fill((200,200,200)) |
|
|
|
|
|
|
|
#Icone |
|
|
|
icone = pygame.image.load(image_icone) |
|
|
@ -25,19 +25,18 @@ pygame.display.set_caption(titre_fenetre) |
|
|
|
|
|
|
|
lst_elements = [] |
|
|
|
|
|
|
|
#BOUCLE PRINCIPALE |
|
|
|
#BOUCLE PRINCIPALE# |
|
|
|
continuer = 1 |
|
|
|
while continuer: |
|
|
|
|
|
|
|
accueil = Image(fenetre, image_acceuil, 0, 0, 205, 205) |
|
|
|
#lst_elements.append(accueil)#il me semble quepas besoin de ca |
|
|
|
accueil.maj() |
|
|
|
|
|
|
|
#Rafraichissement |
|
|
|
pygame.display.flip() |
|
|
|
pygame.display.flip()#Rafraichissement |
|
|
|
|
|
|
|
continuer_jeu, continuer_accueil = 1, 1 #On remet ces variables à 1 à chaque tour de boucle |
|
|
|
|
|
|
|
#BOUCLE D'ACCUEIL |
|
|
|
#BOUCLE D'ACCUEIL# |
|
|
|
while continuer_accueil: |
|
|
|
pygame.time.Clock().tick(30) #Limitation de vitesse de la boucle |
|
|
|
|
|
|
@ -45,7 +44,6 @@ while continuer: |
|
|
|
|
|
|
|
if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE: |
|
|
|
continuer_accueil,continuer_jeu,continuer = 0,0,0#Si l'utilisateur quitte, on met les variables de boucle à 0 pour n'en parcourir aucune et fermer |
|
|
|
|
|
|
|
choix = 0 #Variable de choix du niveau |
|
|
|
|
|
|
|
elif event.type == KEYDOWN: |
|
|
@ -65,41 +63,49 @@ while continuer: |
|
|
|
fonds.creer_Image(img_bg, 0, 0, 290, 57) |
|
|
|
fonds.creer_Image(img_goudron, 0, 360, 205, 205) |
|
|
|
|
|
|
|
lst_nuages = [img_n1, img_n2, img_n3, img_n4, img_n5, img_n6,img_n7] |
|
|
|
nuages = GroupeImage(fenetre) |
|
|
|
nuages.creer_Image(img_n1, 1280, 0, 290, 57) |
|
|
|
nuages.creer_Image(img_n2, 1280, 59, 248, 58) |
|
|
|
nuages.creer_Image(lst_nuages[randint(0,6)], 1280, 0, 290, 57)#(chm_acces, pos_x, pos_y, long, larg) |
|
|
|
nuages.creer_Image(lst_nuages[randint(0,6)], 1280, 59, 248, 58) |
|
|
|
|
|
|
|
barrieres = GroupeImage(fenetre) |
|
|
|
barrieres.creer_Image(img_barriere, 0, 360, 844, 40) |
|
|
|
barrieres.creer_Image(img_barriere, 844, 360, 844, 40) |
|
|
|
barrieres.creer_Image(img_barriere, 844+844, 360, 844, 40) |
|
|
|
|
|
|
|
barrieres.creer_Image(img_barriere, 1688, 360, 844, 40) |
|
|
|
|
|
|
|
ligne_ac = GroupeImage(fenetre) |
|
|
|
ligne_ac.creer_Image(img_lgn_discontinu, 0, 500, 104, 5)#(chm_acces, pos_x, pos_y, long, larg) |
|
|
|
ligne_ac.creer_Image(img_lgn_discontinu, 640, 500, 104, 5) |
|
|
|
ligne_ac.creer_Image(img_lgn_discontinu, 1280, 500, 104, 5) |
|
|
|
|
|
|
|
voitures = GroupeImage(fenetre) |
|
|
|
voitures.creer_Image(img_e30, 50, 360, 205, 205) |
|
|
|
|
|
|
|
fonds.affiche() |
|
|
|
nuages.affiche() |
|
|
|
barrieres.affiche() |
|
|
|
ligne_ac.affiche() |
|
|
|
voitures.affiche() |
|
|
|
|
|
|
|
pygame.display.flip() |
|
|
|
|
|
|
|
if choix == 'n2': |
|
|
|
|
|
|
|
monde = Paysage(fenetre, img_bg_nuit, img_n2, img_goudron, img_barriere) |
|
|
|
monde.creer_monde() |
|
|
|
pygame.display.flip() |
|
|
|
pass |
|
|
|
|
|
|
|
#BOUCLE DE JEU |
|
|
|
while continuer_jeu: |
|
|
|
pygame.time.Clock().tick(30) #Limitation de vitesse de la boucl |
|
|
|
|
|
|
|
nuages.avancer(10) |
|
|
|
barrieres.avancer(10) |
|
|
|
|
|
|
|
|
|
|
|
pygame.time.Clock().tick(30) #Limitation de vitesse de la boucle |
|
|
|
|
|
|
|
nuages.avancer(10,205) |
|
|
|
barrieres.avancer(10,0) |
|
|
|
ligne_ac.avancer(10,1280-104) |
|
|
|
|
|
|
|
fonds.affiche() |
|
|
|
nuages.affiche() |
|
|
|
barrieres.affiche() |
|
|
|
ligne_ac.affiche() |
|
|
|
voitures.affiche() |
|
|
|
|
|
|
|
|
|
|
|
for event in pygame.event.get(): |
|
|
|
|
|
|
|
if event.type == QUIT: |
|
|
@ -113,7 +119,7 @@ while continuer: |
|
|
|
lst_elements[2].translater('y',"haut",10)#deplace pas la voiture |
|
|
|
elif event.key == K_DOWN: |
|
|
|
lst_elements[2].translater('y',"bas",10) |
|
|
|
|
|
|
|
|
|
|
|
pygame.display.flip() |
|
|
|
|
|
|
|
pygame.display.flip() |
|
|
|