Compare commits
3 Commits
de1b9f3638
...
815161945f
Author | SHA1 | Date | |
---|---|---|---|
815161945f | |||
ba315ef495 | |||
ed9dc82541 |
27
main.py
27
main.py
@ -18,21 +18,6 @@ def creer_ananas(pos_x, pos_y):
|
|||||||
ananas.rect.x = pos_x
|
ananas.rect.x = pos_x
|
||||||
ananas.rect.y = pos_y
|
ananas.rect.y = pos_y
|
||||||
return ananas
|
return ananas
|
||||||
|
|
||||||
def tirer_missiles(pos_x, pos_y):
|
|
||||||
missiles = pygame.sprite.Sprite()
|
|
||||||
pygame.sprite.Sprite.__init__(missiles)
|
|
||||||
missiles.image = pygame.image.load("missiles.png").convert_alpha()
|
|
||||||
missiles.image = pygame.transform.scale(missiles.image,[50, 100])
|
|
||||||
missiles.rect = missiles.image.get_rect()
|
|
||||||
missiles.rect.x = pos_x
|
|
||||||
missiles.rect.y = pos_y
|
|
||||||
return missiles
|
|
||||||
|
|
||||||
liste_de_missiles = []
|
|
||||||
liste_sprites_missiles = pygame.sprite.Group()
|
|
||||||
|
|
||||||
pygame.sprite.LayeredUpdates()
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
running = True
|
running = True
|
||||||
@ -81,7 +66,7 @@ texte4.rect = texte4.image.get_rect()
|
|||||||
texte4.rect.centerx = 360
|
texte4.rect.centerx = 360
|
||||||
texte4.rect.centery = 100
|
texte4.rect.centery = 100
|
||||||
liste_des_sprites.add(texte4)
|
liste_des_sprites.add(texte4)
|
||||||
|
|
||||||
police = pygame.font.Font(None, 20)
|
police = pygame.font.Font(None, 20)
|
||||||
texte5 = pygame.sprite.Sprite()
|
texte5 = pygame.sprite.Sprite()
|
||||||
texte5.image = police.render("ALERTE, PLANETE TERRE EST SOUS ATTAQUE", 1, (10, 10, 10),(255, 90, 20))
|
texte5.image = police.render("ALERTE, PLANETE TERRE EST SOUS ATTAQUE", 1, (10, 10, 10),(255, 90, 20))
|
||||||
@ -89,7 +74,7 @@ texte5.rect = texte5.image.get_rect()
|
|||||||
texte5.rect.centerx = 360
|
texte5.rect.centerx = 360
|
||||||
texte5.rect.centery = 1500
|
texte5.rect.centery = 1500
|
||||||
liste_des_sprites.add(texte5)
|
liste_des_sprites.add(texte5)
|
||||||
|
|
||||||
gameover = False
|
gameover = False
|
||||||
score = 0
|
score = 0
|
||||||
|
|
||||||
@ -97,7 +82,6 @@ while running:
|
|||||||
|
|
||||||
liste_des_sprites.draw(fenetre)
|
liste_des_sprites.draw(fenetre)
|
||||||
liste_sprites_ananas.draw(fenetre)
|
liste_sprites_ananas.draw(fenetre)
|
||||||
liste_sprites_missiles.draw(fenetre)
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
@ -105,13 +89,9 @@ while running:
|
|||||||
avion.rect.x = event.pos[0]
|
avion.rect.x = event.pos[0]
|
||||||
if event.type == MOUSEBUTTONDOWN:
|
if event.type == MOUSEBUTTONDOWN:
|
||||||
print("Vous avez tué l'ennemi! Continuez!")
|
print("Vous avez tué l'ennemi! Continuez!")
|
||||||
nouvel_missile = tirer_missiles(avion.rect.centerx, HAUTEUR/2)
|
|
||||||
liste_de_missiles.append(nouvel_missile)
|
|
||||||
liste_sprites_missiles.add(nouvel_missile)
|
|
||||||
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)
|
||||||
liste_des_sprites.remove(texte1)
|
|
||||||
liste_des_sprites.remove(texte2)
|
liste_des_sprites.remove(texte2)
|
||||||
liste_des_sprites.remove(texte3)
|
liste_des_sprites.remove(texte3)
|
||||||
liste_des_sprites.remove(texte4)
|
liste_des_sprites.remove(texte4)
|
||||||
@ -154,12 +134,11 @@ while running:
|
|||||||
police = pygame.font.Font(None, 36)
|
police = pygame.font.Font(None, 36)
|
||||||
texte33 = pygame.sprite.Sprite()
|
texte33 = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(texte33)
|
pygame.sprite.Sprite.__init__(texte33)
|
||||||
texte33.image = police.render("Réessaye de tuer tout les ennemis!", 1, (10,10,10),(255, 90, 20))
|
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 = texte33.image.get_rect()
|
||||||
texte33.rect.centerx = 360
|
texte33.rect.centerx = 360
|
||||||
texte33.rect.centery = 450
|
texte33.rect.centery = 450
|
||||||
liste_des_sprites.add(texte33)
|
liste_des_sprites.add(texte33)
|
||||||
|
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
fenetre.fill((0,0,0))
|
fenetre.fill((0,0,0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user