-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.py
More file actions
123 lines (91 loc) · 3.43 KB
/
start.py
File metadata and controls
123 lines (91 loc) · 3.43 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
121
122
123
import pygame
import pygame_gui
import sys
from piano import start_piano_game
from setting import Settings
pygame.init()
ai_setting = Settings()
screen_width = ai_setting.ScreenWidth_start
screen_height = ai_setting.ScreenHeigth_start
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('Piano Game')
manager = pygame_gui.UIManager(
(ai_setting.ScreenWidth_start, ai_setting.ScreenHeigth_start))
background_image = pygame.image.load("topics/background.jpg")
# حالتهای مختلف بازی
MAIN_MENU = "main_menu"
GAME_SCREEN = "game"
SETTINGS_SCREEN = "settings"
current_screen = MAIN_MENU
# حلقه اصلی بازی
clock = pygame.time.Clock()
is_running = True
manager = pygame_gui.UIManager(
(ai_setting.ScreenWidth_start, ai_setting.ScreenHeigth_start))
# دکمههای صفحه اصلی
start_button = pygame_gui.elements.UIButton(
relative_rect=pygame.Rect((250, 150), (100, 50)),
text='Start Game',
manager=manager
)
settings_button = pygame_gui.elements.UIButton(
relative_rect=pygame.Rect((250, 250), (100, 50)),
text='Settings',
manager=manager
)
back_button = pygame_gui.elements.UIButton(
relative_rect=pygame.Rect((250, 350), (100, 50)),
text='Back',
manager=manager
)
# تنظیمات صفحه نمایش
back_button.hide()
def show_main_menu():
start_button.show()
settings_button.show()
back_button.hide()
def show_game_screen():
start_button.hide()
settings_button.hide()
back_button.show()
start_piano_game() # اینجا تابع شروع بازی پیانو فراخوانی میشود
def show_settings_screen():
start_button.hide()
settings_button.hide()
back_button.show()
while is_running:
time_delta = clock.tick(60) / 1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if current_screen == MAIN_MENU:
if event.type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == start_button:
current_screen = GAME_SCREEN
show_game_screen()
elif event.ui_element == settings_button:
current_screen = SETTINGS_SCREEN
show_settings_screen()
elif current_screen in [GAME_SCREEN, SETTINGS_SCREEN]:
if event.type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == back_button:
current_screen = MAIN_MENU
show_main_menu()
manager.process_events(event)
manager.update(time_delta)
screen.blit(background_image, (0, 0))
# screen.fill((ai_setting.BLACK))
manager.draw_ui(screen)
if current_screen == GAME_SCREEN:
# اینجا کد مربوط به صفحه بازی را اضافه کنید
font = pygame.font.Font(None, 74)
game_text = font.render('Game Screen', True, (255, 255, 255))
screen.blit(game_text, (250, 100))
# این بخش میتواند شامل منطق و رسم گرافیکهای مربوط به بازی پیانو باشد
elif current_screen == SETTINGS_SCREEN:
# اینجا کد مربوط به صفحه تنظیمات را اضافه کنید
font = pygame.font.Font(None, 74)
# این بخش میتواند شامل تنظیمات بازی باشد
pygame.display.update()
pygame.display.flip()
pygame.quit()