Compare commits
4 Commits
b6f1a9c050
...
51c3d571dc
Author | SHA1 | Date | |
---|---|---|---|
51c3d571dc | |||
3e8352aae7 | |||
e7e0d4f5b0 | |||
a7e291809e |
47
main.py
47
main.py
@ -33,10 +33,11 @@ liste_des_sprites.add(fond)
|
||||
liste_sprites_ananas = pygame.sprite.LayeredUpdates()
|
||||
liste_des_sprites.add(avion)
|
||||
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 d’avions spatiaux!", 1, (10, 10, 10),(255, 90, 20))
|
||||
texte.image = police.render("ALERTE! La planète Terre est attaquée par une flotte d’avions spatiaux!", 1, (10, 10, 10),(255, 90, 20))
|
||||
texte.rect = texte.image.get_rect()
|
||||
texte.rect.centerx = 360
|
||||
texte.rect.centery = 30
|
||||
@ -76,7 +77,9 @@ liste_des_sprites.add(texte5)
|
||||
|
||||
gameover = False
|
||||
score = 0
|
||||
|
||||
while running:
|
||||
|
||||
liste_des_sprites.draw(fenetre)
|
||||
liste_sprites_ananas.draw(fenetre)
|
||||
for event in pygame.event.get():
|
||||
@ -84,9 +87,15 @@ while running:
|
||||
running = False
|
||||
if event.type == MOUSEMOTION:
|
||||
avion.rect.x = event.pos[0]
|
||||
if event.type == MOUSEBUTTONDOWN:
|
||||
print("Vous avez tué l'ennemi! Continuez!")
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_SPACE]:
|
||||
liste_des_sprites.remove(texte)
|
||||
liste_des_sprites.remove(texte2)
|
||||
liste_des_sprites.remove(texte3)
|
||||
liste_des_sprites.remove(texte4)
|
||||
liste_des_sprites.remove(texte5)
|
||||
if gameover == False:
|
||||
nombre_aleatoire = randint(0, 100)
|
||||
if nombre_aleatoire == 100:
|
||||
@ -97,20 +106,40 @@ while running:
|
||||
for ananas in liste_d_ananas:
|
||||
ananas.rect.y += 5
|
||||
if ananas.rect.colliderect(avion):
|
||||
print("COLLISION")
|
||||
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ")
|
||||
score += 1
|
||||
liste_d_ananas.remove(ananas)
|
||||
ananas.kill()
|
||||
if ananas.rect.y > HAUTEUR:
|
||||
gameover = True
|
||||
|
||||
police = pygame.font.Font(None, 36)
|
||||
texte = pygame.sprite.Sprite()
|
||||
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.rect = texte.image.get_rect()
|
||||
texte.rect.centerx = 360
|
||||
texte.rect.centery = 450
|
||||
liste_des_sprites.add(texte)
|
||||
texte1 = pygame.sprite.Sprite()
|
||||
pygame.sprite.Sprite.__init__(texte1)
|
||||
texte1.image = police.render("Gameover.", 1, (10,10,10),(255, 90, 20))
|
||||
texte1.rect = texte1.image.get_rect()
|
||||
texte1.rect.centerx = 360
|
||||
texte1.rect.centery = 450
|
||||
liste_des_sprites.add(texte1)
|
||||
|
||||
police = pygame.font.Font(None, 36)
|
||||
texte22 = pygame.sprite.Sprite()
|
||||
pygame.sprite.Sprite.__init__(texte22)
|
||||
texte22.image = police.render("L'ennemi est entré dans notre atmosphère!", 1, (10,10,10),(255, 90, 20))
|
||||
texte22.rect = texte22.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)
|
||||
texte33.image = police.render("L'ennemi est entré dans notre atmosphère!", 1, (10,10,10),(255, 90, 20))
|
||||
texte33.rect = texte33.image.get_rect()
|
||||
texte33.rect.centerx = 360
|
||||
texte33.rect.centery = 450
|
||||
liste_des_sprites.add(texte33)
|
||||
|
||||
pygame.display.flip()
|
||||
fenetre.fill((0,0,0))
|
||||
clock.tick(60)
|
||||
|
BIN
missiles.png
Normal file
BIN
missiles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
Loading…
x
Reference in New Issue
Block a user