caitlin: missiles
This commit is contained in:
parent
fe7f6bc4c8
commit
b7508c1daa
77
main.py
77
main.py
@ -23,7 +23,7 @@ def tirer_missiles(pos_x, pos_y):
|
|||||||
missiles = pygame.sprite.Sprite()
|
missiles = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(missiles)
|
pygame.sprite.Sprite.__init__(missiles)
|
||||||
missiles.image = pygame.image.load("missiles.png").convert_alpha()
|
missiles.image = pygame.image.load("missiles.png").convert_alpha()
|
||||||
missiles.image = pygame.transform.scale(missiles.image,[50, 100])
|
missiles.image = pygame.transform.scale(missiles.image,[10, 100])
|
||||||
missiles.rect = missiles.image.get_rect()
|
missiles.rect = missiles.image.get_rect()
|
||||||
missiles.rect.x = pos_x
|
missiles.rect.x = pos_x
|
||||||
missiles.rect.y = pos_y
|
missiles.rect.y = pos_y
|
||||||
@ -61,7 +61,7 @@ liste_des_sprites.add(texte)
|
|||||||
|
|
||||||
police = pygame.font.Font(None, 20)
|
police = pygame.font.Font(None, 20)
|
||||||
texte2 = pygame.sprite.Sprite()
|
texte2 = pygame.sprite.Sprite()
|
||||||
texte2.image = police.render("Vous vous trouver dans l’engin SU-PER12. Votre mission est d’éliminer le plus d’ennemis possible!", 1, (10, 10, 10),(255, 90, 20))
|
texte2.image = police.render("Vous vous trouvez dans l’engin SU-PER12. Votre mission est d’éliminer le plus d’ennemis possible!", 1, (10, 10, 10),(255, 90, 20))
|
||||||
texte2.rect = texte2.image.get_rect()
|
texte2.rect = texte2.image.get_rect()
|
||||||
texte2.rect.centerx = 360
|
texte2.rect.centerx = 360
|
||||||
texte2.rect.centery = 60
|
texte2.rect.centery = 60
|
||||||
@ -114,9 +114,10 @@ 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!")
|
||||||
nouveau_missile = tirer_missiles(avion.rect.x, HAUTEUR/2)
|
liste_d_ananas.remove(ananas)
|
||||||
liste_de_missiles.append = [nouveau_missile]
|
nouveau_missile = tirer_missiles(avion.rect.centerx, HAUTEUR/2)
|
||||||
liste_sprites_missiles.add = pygame.sprite.Group(nouveau_missile)
|
liste_de_missiles.append(nouveau_missile) == [nouveau_missile]
|
||||||
|
liste_sprites_missiles.add(nouveau_missile) == pygame.sprite.Group(nouveau_missile)
|
||||||
|
|
||||||
if gameover == False:
|
if gameover == False:
|
||||||
nombre_aleatoire = randint(0, 100)
|
nombre_aleatoire = randint(0, 100)
|
||||||
@ -126,40 +127,50 @@ 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 += 5
|
ananas.rect.y += 2
|
||||||
if ananas.rect.colliderect(avion):
|
if ananas.rect.colliderect(avion):
|
||||||
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ")
|
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ, MALHEUREUSEMENT, VOUS AUSSI")
|
||||||
liste_d_ananas.remove(ananas)
|
liste_d_ananas.remove(ananas)
|
||||||
ananas.kill()
|
ananas.kill()
|
||||||
|
gameover = True
|
||||||
if ananas.rect.y > HAUTEUR:
|
if ananas.rect.y > HAUTEUR:
|
||||||
gameover = True
|
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)
|
for missiles in liste_de_missiles:
|
||||||
texte22 = pygame.sprite.Sprite()
|
ananas.rect.y -= 1
|
||||||
pygame.sprite.Sprite.__init__(texte22)
|
if missiles.rect.colliderect(ananas):
|
||||||
texte22.image = police.render("L'ennemi est entré dans notre atmosphère!", 1, (10,10,10),(255, 90, 20))
|
print("COLLISION, L'OBJET A ÉTÉ ÉLIMINÉ")
|
||||||
texte22.rect = texte22.image.get_rect()
|
liste_de_missiles.remove(missiles)
|
||||||
texte22.rect.centerx = 360
|
ananas.kill()
|
||||||
texte22.rect.centery = 500
|
if ananas.rect.y <= 0:
|
||||||
liste_des_sprites.add(texte22)
|
gameover = True
|
||||||
|
|
||||||
police = pygame.font.Font(None, 36)
|
police = pygame.font.Font(None, 36)
|
||||||
texte33 = pygame.sprite.Sprite()
|
texte1 = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(texte33)
|
pygame.sprite.Sprite.__init__(texte1)
|
||||||
texte33.image = police.render("Réessaye de tuer tout les ennemis!", 1, (10,10,10),(255, 90, 20))
|
texte1.image = police.render("Gameover.", 1, (10,10,10),(255, 90, 20))
|
||||||
texte33.rect = texte33.image.get_rect()
|
texte1.rect = texte1.image.get_rect()
|
||||||
texte33.rect.centerx = 360
|
texte1.rect.centerx = 360
|
||||||
texte33.rect.centery = 450
|
texte1.rect.centery = 450
|
||||||
liste_des_sprites.add(texte33)
|
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("Réessaye de tuer tout les ennemis!", 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()
|
pygame.display.flip()
|
||||||
fenetre.fill((0,0,0))
|
fenetre.fill((0,0,0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user