1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #Importation des bibliothèques nécessaires
import pygame, sys
from pygame.locals import *
#Initialisation de la bibliothèque Pygame
pygame.init()
#Création de la fenêtre
fenetre = pygame.display.set_mode((640, 480))
#Variable qui continue la boucle si = 1, stoppe si = 0
continuer = 1
vie_perso = 100
gris = 125,125,125
tableau1 = pygame.image.load("Textures/JeuAdds/tableau1.png").convert_alpha()
fontopt = pygame.font.SysFont('Corbel', 26, bold=True)
vietxt = fontopt.render(str(vie_perso),1,(gris))
fenetre.blit(tableau1,(320, 240))
fenetre.blit(vietxt,(370, 270))
pygame.display.flip()
#Boucle infinie
while continuer:
for event in pygame.event.get():
if event.type == pygame.QUIT: #QUIT est un module de PyGame
pygame.quit()
sys.exit()
if event.type == MOUSEBUTTONDOWN and event.button == 1:
if event.pos[0] > 0 and event.pos[0] < 640 and event.pos[1] > 0 and event.pos[1] < 480:
vie_perso = vie_perso - 20
print(str(vie_perso))
fenetre.blit(tableau1,(320, 240))
fenetre.blit(vietxt,(370, 270))
pygame.display.update() |
Partager