caitlin: missiles
This commit is contained in:
parent
b7508c1daa
commit
f12bd0b5e8
45
main.py
45
main.py
@ -69,7 +69,7 @@ liste_des_sprites.add(texte2)
|
|||||||
|
|
||||||
police = pygame.font.Font(None, 20)
|
police = pygame.font.Font(None, 20)
|
||||||
texte3 = pygame.sprite.Sprite()
|
texte3 = 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))
|
texte3.image = police.render("Pour ce faire, appuyez sur votre souris pour tirer et manoeuvrer votre SU-PER12!", 1, (10, 10, 10),(255, 90, 20))
|
||||||
texte3.rect = texte3.image.get_rect()
|
texte3.rect = texte3.image.get_rect()
|
||||||
texte3.rect.centerx = 360
|
texte3.rect.centerx = 360
|
||||||
texte3.rect.centery = 80
|
texte3.rect.centery = 80
|
||||||
@ -93,6 +93,8 @@ liste_des_sprites.add(texte5)
|
|||||||
|
|
||||||
gameover = False
|
gameover = False
|
||||||
|
|
||||||
|
ananas_speed = 4
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
|
|
||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
@ -114,7 +116,6 @@ 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!")
|
||||||
liste_d_ananas.remove(ananas)
|
|
||||||
nouveau_missile = tirer_missiles(avion.rect.centerx, HAUTEUR/2)
|
nouveau_missile = tirer_missiles(avion.rect.centerx, HAUTEUR/2)
|
||||||
liste_de_missiles.append(nouveau_missile) == [nouveau_missile]
|
liste_de_missiles.append(nouveau_missile) == [nouveau_missile]
|
||||||
liste_sprites_missiles.add(nouveau_missile) == pygame.sprite.Group(nouveau_missile)
|
liste_sprites_missiles.add(nouveau_missile) == pygame.sprite.Group(nouveau_missile)
|
||||||
@ -127,7 +128,7 @@ while running:
|
|||||||
liste_d_ananas.append(nouvel_ananas)
|
liste_d_ananas.append(nouvel_ananas)
|
||||||
liste_sprites_ananas.add(nouvel_ananas)
|
liste_sprites_ananas.add(nouvel_ananas)
|
||||||
for ananas in liste_d_ananas:
|
for ananas in liste_d_ananas:
|
||||||
ananas.rect.y += 2
|
ananas.rect.y += ananas_speed
|
||||||
if ananas.rect.colliderect(avion):
|
if ananas.rect.colliderect(avion):
|
||||||
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ, MALHEUREUSEMENT, VOUS AUSSI")
|
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ, MALHEUREUSEMENT, VOUS AUSSI")
|
||||||
liste_d_ananas.remove(ananas)
|
liste_d_ananas.remove(ananas)
|
||||||
@ -135,29 +136,10 @@ while running:
|
|||||||
gameover = True
|
gameover = True
|
||||||
if ananas.rect.y > HAUTEUR:
|
if ananas.rect.y > HAUTEUR:
|
||||||
gameover = True
|
gameover = True
|
||||||
|
|
||||||
for missiles in liste_de_missiles:
|
|
||||||
ananas.rect.y -= 1
|
|
||||||
if missiles.rect.colliderect(ananas):
|
|
||||||
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ")
|
|
||||||
liste_de_missiles.remove(missiles)
|
|
||||||
ananas.kill()
|
|
||||||
if ananas.rect.y <= 0:
|
|
||||||
gameover = True
|
|
||||||
|
|
||||||
police = pygame.font.Font(None, 36)
|
|
||||||
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)
|
police = pygame.font.Font(None, 36)
|
||||||
texte22 = pygame.sprite.Sprite()
|
texte22 = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(texte22)
|
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.image = police.render("Réessaye de tuer tout les ennemis!", 1, (10,10,10),(255, 90, 20))
|
||||||
texte22.rect = texte22.image.get_rect()
|
texte22.rect = texte22.image.get_rect()
|
||||||
texte22.rect.centerx = 360
|
texte22.rect.centerx = 360
|
||||||
texte22.rect.centery = 500
|
texte22.rect.centery = 500
|
||||||
@ -166,13 +148,26 @@ 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)
|
||||||
|
|
||||||
|
for missiles in liste_de_missiles:
|
||||||
|
missiles.rect.y -= 10
|
||||||
|
if missiles.rect.y <= 0:
|
||||||
|
liste_de_missiles.remove(missiles)
|
||||||
|
missiles.kill()
|
||||||
|
else:
|
||||||
|
for ananas in liste_d_ananas:
|
||||||
|
if ananas.rect.colliderect(missiles):
|
||||||
|
liste_d_ananas.remove(ananas)
|
||||||
|
ananas.kill()
|
||||||
|
liste_de_missiles.remove(missiles)
|
||||||
|
missiles.kill()
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
fenetre.fill((0,0,0))
|
fenetre.fill((0,0,0))
|
||||||
clock.tick(60)
|
clock.tick(50)
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user