mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-09 19:30:40 +00:00
Auto urgent commit.
This commit is contained in:
42
pygame/bouncing_ball_project/ball.py
Normal file
42
pygame/bouncing_ball_project/ball.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import sys, pygame
|
||||
import balle
|
||||
##########Definitions des constantes
|
||||
# Taille de la fenetre
|
||||
LARGEUR_ECRAN = 600
|
||||
HAUTEUR_ECRAN = 800
|
||||
# Couleur
|
||||
BLANC = (255, 255, 255)
|
||||
NOIR = (0, 0, 0)
|
||||
|
||||
pygame.init() #initialisation des modules de pygame
|
||||
|
||||
# Creation de la fenetre
|
||||
ecran = pygame.display.set_mode((LARGEUR_ECRAN, HAUTEUR_ECRAN))
|
||||
ecran.fill(BLANC)
|
||||
|
||||
pygame.display.set_caption('Balle rebondissante')
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
b1 = balle.Balle()
|
||||
|
||||
bouge = False
|
||||
|
||||
while True: #Demarrage de la boucle infinie
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT: #Evt de sortie de boucle
|
||||
sys.exit()
|
||||
elif event.type == pygame.MOUSEBUTTONDOWN:
|
||||
bouge = not bouge
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
|
||||
bouge = not bouge
|
||||
|
||||
|
||||
ecran.fill(BLANC)
|
||||
if bouge:
|
||||
b1.deplace()
|
||||
b1.affiche(ecran)
|
||||
|
||||
pygame.display.update() #rafraichissement
|
||||
clock.tick(60)
|
||||
|
||||
Reference in New Issue
Block a user