-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
76 lines (54 loc) · 3.22 KB
/
Main.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from Main_Screen import Main_Screen
import pygame # Importation du module Pygame
# Initialisation de Pygame
pygame.init() # Initialise les modules de Pygame
updated_rects = [] # Liste des rectangles de l'écran qui ont été mis à jour
# Constantes pour la taille de l'écran et de la grille de jeu
SCREEN_WIDTH = 720 # Largeur de l'écran
SCREEN_HEIGHT = 480 # Taille de l'écran
GRID_SIZE = (SCREEN_WIDTH - 250) // 8 # Taille d'une case du plateau de jeu
# Couleurs
WHITE = (255, 255, 255) # Blanc
BLACK = (0, 0, 0) # Noir
GRAY = (128, 128, 128) # Gris
GREEN = (0, 255, 0) # Vert
RED = (255, 0, 0) # Rouge
BROWN = (165, 42, 42) # Marron
# Chargement du background
BACKGROUND_IMG = pygame.image.load('Background.png') # Charge l'image du background
BACKGROUND_IMG = pygame.transform.scale(BACKGROUND_IMG,
(SCREEN_WIDTH + 350, SCREEN_HEIGHT + 40)) # Redimensionne l'image du background
BACKGROUND_IMG2 = pygame.image.load('Background2.png') # Charge l'image du background
BACKGROUND_IMG2 = pygame.transform.scale(BACKGROUND_IMG2,
(SCREEN_WIDTH, SCREEN_HEIGHT)) # Redimensionne l'image du background
# Chargement des images des pièces
DEFAULT_IMAGE_SIZE = (64, 64)
PAWN_WHITE_IMG = pygame.image.load('pieces/pawn_white.png')
PAWN_WHITE_IMG = pygame.transform.scale(PAWN_WHITE_IMG, DEFAULT_IMAGE_SIZE)
PAWN_BLACK_IMG = pygame.image.load('pieces/pawn_black.png')
PAWN_BLACK_IMG = pygame.transform.scale(PAWN_BLACK_IMG, DEFAULT_IMAGE_SIZE)
ROOK_WHITE_IMG = pygame.image.load('pieces/rook_white.png')
ROOK_WHITE_IMG = pygame.transform.scale(ROOK_WHITE_IMG, DEFAULT_IMAGE_SIZE)
ROOK_BLACK_IMG = pygame.image.load('pieces/rook_black.png')
ROOK_BLACK_IMG = pygame.transform.scale(ROOK_BLACK_IMG, DEFAULT_IMAGE_SIZE)
KNIGHT_WHITE_IMG = pygame.image.load('pieces/knight_white.png')
KNIGHT_WHITE_IMG = pygame.transform.scale(KNIGHT_WHITE_IMG, DEFAULT_IMAGE_SIZE)
KNIGHT_BLACK_IMG = pygame.image.load('pieces/knight_black.png')
KNIGHT_BLACK_IMG = pygame.transform.scale(KNIGHT_BLACK_IMG, DEFAULT_IMAGE_SIZE)
BISHOP_WHITE_IMG = pygame.image.load('pieces/bishop_white.png')
BISHOP_WHITE_IMG = pygame.transform.scale(BISHOP_WHITE_IMG, DEFAULT_IMAGE_SIZE)
BISHOP_BLACK_IMG = pygame.image.load('pieces/bishop_black.png')
BISHOP_BLACK_IMG = pygame.transform.scale(BISHOP_BLACK_IMG, DEFAULT_IMAGE_SIZE)
QUEEN_WHITE_IMG = pygame.image.load('pieces/queen_white.png')
QUEEN_WHITE_IMG = pygame.transform.scale(QUEEN_WHITE_IMG, DEFAULT_IMAGE_SIZE)
QUEEN_BLACK_IMG = pygame.image.load('pieces/queen_black.png')
QUEEN_BLACK_IMG = pygame.transform.scale(QUEEN_BLACK_IMG, DEFAULT_IMAGE_SIZE)
KING_WHITE_IMG = pygame.image.load('pieces/king_white.png')
KING_WHITE_IMG = pygame.transform.scale(KING_WHITE_IMG, DEFAULT_IMAGE_SIZE)
KING_BLACK_IMG = pygame.image.load('pieces/king_black.png')
KING_BLACK_IMG = pygame.transform.scale(KING_BLACK_IMG, DEFAULT_IMAGE_SIZE)
# Classe pour représenter les pièces du jeu d'échecs
if __name__ == '__main__': # Si on lance le script
pygame.init() # On initialise pygame
main_screen = Main_Screen() # On lance l'écran d'accueil
main_screen.run() # On lance l'écran d'accueil