-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
120 lines (97 loc) · 3.81 KB
/
main.py
File metadata and controls
120 lines (97 loc) · 3.81 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import pygame
import sys
import os
import ctypes # Potrzebne do naprawy ikonki na pasku zadań
#importy z innych plikow
from core.settings import *
from core.sound_manager import SoundManager
from core.menu import Menu
from games.blackjack import BlackjackGame, Card, Button, Deck, Hand
from games.crash import CrashGame
from core.ui_elements import Manager
from core.intro import IntroSequence
from core.wallet import Wallet
def main():
skip_intro = "--skip" in sys.argv or "--skip-intro" in sys.argv
# --- NAPRAWA IKONKI NA PASKU ZADAŃ (WINDOWS) ---
# Ta sekcja informuje Windows, że to jest oddzielna aplikacja, a nie skrypt Pythona.
# Dzięki temu ikonka na pasku zadań nie będzie domyślnym logo Pythona.
try:
myappid = 'mycompany.pyvegas.casino.1.0' # Dowolny unikalny ciąg znaków
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except:
pass
#inicjalizacja modulow pygame
pygame.init()
#inicjalizacja miksera dzwiekow
pygame.mixer.init()
sm = SoundManager()
sm.load_common_sounds()
sm.load_blackjack_sounds()
sm.load_crash_sounds()
Manager.sm = sm
#tworzenie 'screen', czyli glownego okna gry
screen=pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
# --- TYTUŁ I IKONKA ---
pygame.display.set_caption("PyVegas")
icon_path = os.path.join("assets", "images", "ikonka.png")
if os.path.exists(icon_path):
icon = pygame.image.load(icon_path).convert_alpha()
icon = pygame.transform.smoothscale(icon, (64, 64))
pygame.display.set_icon(icon)
else:
print(f"Warning: Icon file not found at {icon_path}")
#odpowiada za FPS
clock=pygame.time.Clock()
#tu jest intro
if not skip_intro:
intro = IntroSequence(screen, sm)
intro.run()
menu = Menu(screen, sm, wallet=Wallet(STARTING_MONEY))
game = None
app_state ="MENU"
running = True
#GLOWNA PETLA
while running:
if app_state == "MENU":
action = menu.update()
menu.draw()
if action == "EXIT_APP":
running = False
elif action == "BLACKJACK":
game = BlackjackGame(screen, sm, wallet=menu.wallet)
game_curr = 'BLACKJACK'
app_state = "GAME"
elif action == "CRASH":
game = CrashGame(screen, sm, wallet=menu.wallet)
game_curr = 'CRASH'
app_state = "GAME"
elif app_state == "GAME":
if game:
game.update()
menu.wallet.save()
for event in pygame.event.get():
if event.type == pygame.QUIT: running = False
# Obsługa ESC - sprawdzamy czy gra pozwala na wyjście
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
if hasattr(game, 'can_exit') and game.can_exit():
app_state = "MENU"
if game_curr == 'CRASH':
sm.set_volume_music(sm.exit_volume_music)
sm.play_music()
game = None
if game: game.handle_input(event)
# Sprawdzanie czy gra sama poprosiła o wyjście
if game and game.exit_requested:
app_state = "MENU"
if game_curr == "CRASH":
sm.set_volume_music(sm.exit_volume_music)
sm.play_music()
game = None
if game: game.draw()
pygame.display.flip()
clock.tick(FPS)
pygame.quit()
sys.exit()
if __name__=="__main__":
main()