caitlin: missiles.png and peng

This commit is contained in:
Stefan Liebl 2025-01-01 13:10:00 +01:00
parent 914d66b2fd
commit a7e291809e
2 changed files with 86 additions and 46 deletions

130
main.py
View File

@ -33,50 +33,68 @@ liste_des_sprites.add(fond)
liste_sprites_ananas = pygame.sprite.LayeredUpdates() liste_sprites_ananas = pygame.sprite.LayeredUpdates()
liste_des_sprites.add(avion) liste_des_sprites.add(avion)
liste_d_ananas = [] liste_d_ananas = []
police = pygame.font.Font(None, 25)
texte = pygame.sprite.Sprite()
pygame.sprite.Sprite.__init__(texte)
texte.image = police.render("ALERTE! La planète terre est attaquée par une flotte davions spatiaux!", 1, (10, 10, 10),(255, 90, 20))
texte.rect = texte.image.get_rect()
texte.rect.centerx = 360
texte.rect.centery = 30
liste_des_sprites.add(texte)
police = pygame.font.Font(None, 20) if running == True:
texte2 = pygame.sprite.Sprite() keys = pygame.key.get_pressed()
texte2.image = police.render("Vous vous trouver dans lengin SU-PER12. Votre mission est déliminer le plus dennemis possible!", 1, (10, 10, 10),(255, 90, 20))
texte2.rect = texte2.image.get_rect()
texte2.rect.centerx = 360
texte2.rect.centery = 60
liste_des_sprites.add(texte2)
police = pygame.font.Font(None, 20) police = pygame.font.Font(None, 25)
texte3 = pygame.sprite.Sprite() texte = pygame.sprite.Sprite()
texte3.image = police.render("Pour ce faire, appuyez sur « espace » pour tirer et bougez la souris pour manoeuvrer votre SU-PER12!", 1, (10, 10, 10),(255, 90, 20)) pygame.sprite.Sprite.__init__(texte)
texte3.rect = texte3.image.get_rect() texte.image = police.render("ALERTE! La planète Terre est attaquée par une flotte davions spatiaux!", 1, (10, 10, 10),(255, 90, 20))
texte3.rect.centerx = 360 texte.rect = texte.image.get_rect()
texte3.rect.centery = 80 texte.rect.centerx = 360
liste_des_sprites.add(texte3) texte.rect.centery = 30
liste_des_sprites.add(texte)
if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte)
police = pygame.font.Font(None, 20) police = pygame.font.Font(None, 20)
texte4 = pygame.sprite.Sprite() texte2 = pygame.sprite.Sprite()
texte4.image = police.render("Bonne chance!", 1, (10, 10, 10),(255, 90, 20)) texte2.image = police.render("Vous vous trouver dans lengin SU-PER12. Votre mission est déliminer le plus dennemis possible!", 1, (10, 10, 10),(255, 90, 20))
texte4.rect = texte4.image.get_rect() texte2.rect = texte2.image.get_rect()
texte4.rect.centerx = 360 texte2.rect.centerx = 360
texte4.rect.centery = 100 texte2.rect.centery = 60
liste_des_sprites.add(texte4) liste_des_sprites.add(texte2)
if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte2)
police = pygame.font.Font(None, 20) police = pygame.font.Font(None, 20)
texte5 = pygame.sprite.Sprite() texte3 = pygame.sprite.Sprite()
texte5.image = police.render("ALERTE, PLANETE TERRE EST SOUS ATTAQUE", 1, (10, 10, 10),(255, 90, 20)) texte3.image = police.render("Pour ce faire, appuyez sur « espace » pour tirer et bougez la souris pour manoeuvrer votre SU-PER12!", 1, (10, 10, 10),(255, 90, 20))
texte5.rect = texte5.image.get_rect() texte3.rect = texte3.image.get_rect()
texte5.rect.centerx = 360 texte3.rect.centerx = 360
texte5.rect.centery = 1500 texte3.rect.centery = 80
liste_des_sprites.add(texte5) liste_des_sprites.add(texte3)
if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte3)
police = pygame.font.Font(None, 20)
texte4 = pygame.sprite.Sprite()
texte4.image = police.render("Bonne chance!", 1, (10, 10, 10),(255, 90, 20))
texte4.rect = texte4.image.get_rect()
texte4.rect.centerx = 360
texte4.rect.centery = 100
liste_des_sprites.add(texte4)
if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte4)
police = pygame.font.Font(None, 20)
texte5 = pygame.sprite.Sprite()
texte5.image = police.render("ALERTE, PLANETE TERRE EST SOUS ATTAQUE", 1, (10, 10, 10),(255, 90, 20))
texte5.rect = texte5.image.get_rect()
texte5.rect.centerx = 360
texte5.rect.centery = 1500
liste_des_sprites.add(texte5)
if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte5)
gameover = False
score = 0
gameover = False
score = 0
while running: while running:
liste_des_sprites.draw(fenetre) liste_des_sprites.draw(fenetre)
liste_sprites_ananas.draw(fenetre) liste_sprites_ananas.draw(fenetre)
for event in pygame.event.get(): for event in pygame.event.get():
@ -84,6 +102,8 @@ while running:
running = False running = False
if event.type == MOUSEMOTION: if event.type == MOUSEMOTION:
avion.rect.x = event.pos[0] avion.rect.x = event.pos[0]
if event.type == MOUSEBUTTONDOWN:
print("Vous avez tué l'ennemi! Continuez!")
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]: if keys[pygame.K_SPACE]:
liste_des_sprites.remove(texte) liste_des_sprites.remove(texte)
@ -97,20 +117,40 @@ while running:
for ananas in liste_d_ananas: for ananas in liste_d_ananas:
ananas.rect.y += 5 ananas.rect.y += 5
if ananas.rect.colliderect(avion): if ananas.rect.colliderect(avion):
print("COLLISION") print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ")
score += 1 score += 1
liste_d_ananas.remove(ananas) liste_d_ananas.remove(ananas)
ananas.kill() ananas.kill()
if ananas.rect.y > HAUTEUR: if ananas.rect.y > HAUTEUR:
gameover = True gameover = True
police = pygame.font.Font(None, 36) police = pygame.font.Font(None, 36)
texte = pygame.sprite.Sprite() texte1 = pygame.sprite.Sprite()
pygame.sprite.Sprite.__init__(texte) pygame.sprite.Sprite.__init__(texte)
texte.image = police.render("Gameover. L'ennemi est entré dans notre atmosphère! Réessaye de tuer tout les ennemis! Score : "+ str(score), 1, (10, 10, 10),(255, 90, 20)) texte.image = police.render("Gameover.", 1, (10,10,10),(255, 90, 20))
texte.rect = texte.image.get_rect() texte1.rect = texte.image.get_rect()
texte.rect.centerx = 360 texte1.rect.centerx = 360
texte.rect.centery = 450 texte1.rect.centery = 450
liste_des_sprites.add(texte) liste_des_sprites.add(texte1)
police = pygame.font.Font(None, 36)
texte22 = pygame.sprite.Sprite()
pygame.sprite.Sprite.__init__(texte22)
texte.image = police.render("L'ennemi est entré dans notre atmosphère!", 1, (10,10,10),(255, 90, 20))
texte22.rect = texte.image.get_rect()
texte22.rect.centerx = 360
texte22.rect.centery = 500
liste_des_sprites.add(texte22)
police = pygame.font.Font(None, 36)
texte33 = pygame.sprite.Sprite()
pygame.sprite.Sprite.__init__(texte33)
texte.image = police.render("L'ennemi est entré dans notre atmosphère!", 1, (10,10,10),(255, 90, 20))
texte33.rect = texte.image.get_rect()
texte33.rect.centerx = 360
texte33.rect.centery = 450
liste_des_sprites.add(texte33)
pygame.display.flip() pygame.display.flip()
fenetre.fill((0,0,0)) fenetre.fill((0,0,0))
clock.tick(60) clock.tick(60)

BIN
missiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB