caitlin: fixes (starting)
This commit is contained in:
parent
260eaa8202
commit
d853a442aa
@ -1,18 +1,14 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
from random import randint
|
from random import randint
|
||||||
|
LARGEUR = 900
|
||||||
|
|
||||||
LARGEUR = 700
|
|
||||||
HAUTEUR = 700
|
HAUTEUR = 700
|
||||||
fenetre = pygame.display.set_mode((LARGEUR, HAUTEUR))
|
fenetre = pygame.display.set_mode((LARGEUR, HAUTEUR))
|
||||||
fond = pygame.sprite.Sprite()
|
fond = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(fond)
|
|
||||||
fond.image = pygame.image.load("terre.jpg").convert()
|
fond.image = pygame.image.load("terre.jpg").convert()
|
||||||
fond.rect = fond.image.get_rect()
|
fond.rect = fond.image.get_rect()
|
||||||
fond.rect.x = 0
|
fond.rect.x = 55
|
||||||
fond.rect.y = 0
|
fond.rect.y = 0
|
||||||
|
|
||||||
def creer_ananas(pos_x, pos_y):
|
def creer_ananas(pos_x, pos_y):
|
||||||
ananas = pygame.sprite.Sprite()
|
ananas = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(ananas)
|
pygame.sprite.Sprite.__init__(ananas)
|
||||||
@ -21,9 +17,7 @@ def creer_ananas(pos_x, pos_y):
|
|||||||
ananas.rect = ananas.image.get_rect()
|
ananas.rect = ananas.image.get_rect()
|
||||||
ananas.rect.x = pos_x
|
ananas.rect.x = pos_x
|
||||||
ananas.rect.y = pos_y
|
ananas.rect.y = pos_y
|
||||||
|
|
||||||
return ananas
|
return ananas
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
running = True
|
running = True
|
||||||
@ -34,57 +28,56 @@ avion.image = pygame.transform.scale(avion.image,[120, 120])
|
|||||||
avion.rect = avion.image.get_rect()
|
avion.rect = avion.image.get_rect()
|
||||||
avion.rect.x = 200
|
avion.rect.x = 200
|
||||||
avion.rect.y = 400
|
avion.rect.y = 400
|
||||||
|
|
||||||
|
|
||||||
liste_des_sprites = pygame.sprite.LayeredUpdates()
|
liste_des_sprites = pygame.sprite.LayeredUpdates()
|
||||||
liste_des_sprites.add(fond)
|
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)
|
||||||
|
|
||||||
police = pygame.font.Font(None, 30)
|
|
||||||
texte = pygame.sprite.Sprite()
|
texte = pygame.sprite.Sprite()
|
||||||
pygame.sprite.Sprite.__init__(texte)
|
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 = texte.image.get_rect()
|
||||||
texte.rect.centerx = fenetre.get_rect().centerx
|
texte.rect.centerx = 360
|
||||||
texte.rect.centery = fenetre.get_rect().centery
|
texte.rect.centery = 30
|
||||||
liste_des_sprites.add(texte)
|
liste_des_sprites.add(texte)
|
||||||
|
|
||||||
|
police = pygame.font.Font(None, 20)
|
||||||
|
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 trouver 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 = 50
|
texte2.rect.centerx = 360
|
||||||
texte2.rect.centery = 70
|
texte2.rect.centery = 60
|
||||||
liste_des_sprites.add(texte2)
|
liste_des_sprites.add(texte2)
|
||||||
|
|
||||||
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))
|
police = pygame.font.Font(None, 20)
|
||||||
|
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.rect = texte3.image.get_rect()
|
texte3.rect = texte3.image.get_rect()
|
||||||
texte3.rect.centerx = 60
|
texte3.rect.centerx = 360
|
||||||
texte3.rect.centery = 80
|
texte3.rect.centery = 80
|
||||||
liste_des_sprites.add(texte3)
|
liste_des_sprites.add(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.image = police.render("Bonne chance!", 1, (10, 10, 10),(255, 90, 20))
|
||||||
texte4.rect = texte4.image.get_rect()
|
texte4.rect = texte4.image.get_rect()
|
||||||
texte4.rect.centerx = 70
|
texte4.rect.centerx = 360
|
||||||
texte4.rect.centery = 90
|
texte4.rect.centery = 100
|
||||||
liste_des_sprites.add(texte4)
|
liste_des_sprites.add(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.image = police.render("ALERTE, PLANETE TERRE EST SOUS ATTAQUE", 1, (10, 10, 10),(255, 90, 20))
|
||||||
texte5.rect = texte5.image.get_rect()
|
texte5.rect = texte5.image.get_rect()
|
||||||
texte5.rect.centerx = 80
|
texte5.rect.centerx = 360
|
||||||
texte5.rect.centery = 100
|
texte5.rect.centery = 1500
|
||||||
liste_des_sprites.add(texte5)
|
liste_des_sprites.add(texte5)
|
||||||
|
|
||||||
gameover = False
|
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():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
@ -100,7 +93,6 @@ while running:
|
|||||||
nouvel_ananas = creer_ananas(position_x_aleatoire, -100)
|
nouvel_ananas = creer_ananas(position_x_aleatoire, -100)
|
||||||
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 += 5
|
||||||
if ananas.rect.colliderect(avion):
|
if ananas.rect.colliderect(avion):
|
||||||
@ -115,8 +107,8 @@ while running:
|
|||||||
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. 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 = texte.image.get_rect()
|
||||||
texte.rect.centerx = fenetre.get_rect().centerx
|
texte.rect.centerx = 360
|
||||||
texte.rect.centery = fenetre.get_rect().centery
|
texte.rect.centery = 450
|
||||||
liste_des_sprites.add(texte)
|
liste_des_sprites.add(texte)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
fenetre.fill((36,242,232))
|
fenetre.fill((36,242,232))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user