-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcert93.py
More file actions
97 lines (75 loc) · 2.98 KB
/
cert93.py
File metadata and controls
97 lines (75 loc) · 2.98 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! python3
import pygame
from error_codes import ERROR_CODES_TEXT, Error_codes
import incidents
import input_manager
import resources
import settings
import time
# pip install pypiwin32
import win32api
import win32con
import win32gui
from tkinter import *
from tkinter import messagebox
from game import Game
from helper_tools import create_level_pickles
def __run_game() -> None:
# Initialisation de l'engin de jeu (pygame)
pygame.init()
pygame.mixer.init()
pygame.joystick.init()
# Initialisation de la fenetre a la bonne taille, sans frame
screen = pygame.display.set_mode(
(settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT), pygame.NOFRAME)
# Definir le fuschia comme la couleur a rendre transparente (une couleur peu commune)
fuchsia = (24, 32, 48)
screen.fill(fuchsia) # Remplir le background de fuschia
# Recuperer le handle de la fenetre
hwnd = pygame.display.get_wm_info()["window"]
# Mettre la fenetre en mode layered (permet la transparence et meilleur pour les jeux/medias)
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(
hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
# Set les attribus suivants sur la fenetre layered:
# la couleur cle est fuchsia, l'opacite de cette couleur est 0, et le mode est transparence par cle
win32gui.SetLayeredWindowAttributes(
hwnd, win32api.RGB(*fuchsia), 0, win32con.LWA_COLORKEY)
# Splash logo dev
splash_screen("img\logo_stacknoodles.png", 1, screen)
# Splash screen logo jeu
splash_screen("img\logo_cert93.png", 2, screen)
# Enlever les settings d'opacité à la fenêtre layered
win32gui.SetLayeredWindowAttributes(
hwnd, win32api.RGB(*fuchsia), 255, win32con.LWA_ALPHA)
# Création de la fenêtre de jeu
pygame.display.set_caption("CERT-93")
screen = pygame.display.set_mode(
(settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT))
# Initialisation des ressources spécifiques au jeu
return_code = resources.init()
if return_code != Error_codes.SUCCES:
pygame.quit()
messagebox.showerror(
"ERREUR", ERROR_CODES_TEXT[return_code] + "\n(Code : " + str(return_code) + ")")
quit()
input_manager.init()
incidents.init()
game = Game(screen)
game.run()
pygame.quit()
def splash_screen(image_path: str, time_up: int, screen: pygame.display.set_mode) -> None:
splash_image = pygame.image.load(image_path)
origin_x = (settings.SCREEN_WIDTH/2) - (splash_image.get_width()/2)
origin_y = (settings.SCREEN_HEIGHT/2) - (splash_image.get_height()/2)
screen.blit(splash_image, (origin_x, origin_y))
pygame.display.update()
time.sleep(3)
if __name__ == '__main__':
create_level_pickles(1)
create_level_pickles(2)
create_level_pickles(3)
try:
__run_game()
except KeyboardInterrupt:
pygame.quit()
quit()