-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
170 lines (127 loc) · 7.17 KB
/
main.py
File metadata and controls
170 lines (127 loc) · 7.17 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
'''
Main loop
Rythm game version 1.0 released!
- Currently one song available but you can add songs and choose them
- Currently one chart available
- offset/speed adjustments
Tile types
- node: press F,G,H,J at appropriate time
- hold: keep pressing F,G,H,J until hold ends. It will keep check whether player is holding itself at regularly selected time
'''
import pygame
from variables import *
from utility_functions import *
from music_ import *
from text_writer import *
from image_processor import *
from chart import *
from screen_options import *
from song_selection import *
pygame.init() # 파이게임 초기화
clock = pygame.time.Clock()
# computer screen size: 1920 x 1080
screen = pygame.display.set_mode((width, height)) # window 생성
pygame.display.set_caption('Rythm Game') # window title
# width, height = pygame.display.get_surface().get_size() # window width, height
screen.fill(background_color[0]) # background color
# main screen ---------------------------------------------------
run = True
meta_run = True
def exit():
pygame.quit()
return False, False
while meta_run:
global stage_speed, offset, judgement_shown, guide_line_shown, high_quality_verifying_graphics, music_list, music_pointer, song_name
# The Music in main
music_Q(lobbyMusic,True)
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT: # 윈도우를 닫으면 종료
run, meta_run = exit()
break
if event.type == pygame.MOUSEMOTION:
# player가 마우스를 따라가도록
# point.pos = pygame.mouse.get_pos()
pass
if event.type == pygame.MOUSEBUTTONUP:
(xp, yp) = pygame.mouse.get_pos()
mouse_particle_list.append((pygame.time.get_ticks(),(xp, yp)))
mouse_click_sound()
if abs(xp - option_key_x_level) < big_text*6:
if abs(yp - (option_key_y_level)) < big_text:
print('option clicked!')
run = False
stage_speed, offset, judgement_shown, guide_line_shown, high_quality_verifying_graphics = option_screen(screen,clock,stage_speed, offset, judgement_shown, guide_line_shown, high_quality_verifying_graphics)
#print(stage_speed, offset, judgement_shown, guide_line_shown, high_quality_verifying_graphics)
break
if abs(xp - song_selection_key_x_level) < big_text*6:
if abs(yp - (song_selection_key_y_level)) < big_text:
print('song selection clicked!')
run = False
music_list, music_pointer, song_name = song_selection_screen(screen,clock,stage_speed, offset, judgement_shown, guide_line_shown, high_quality_verifying_graphics)
#print(music_list, music_pointer, song_name)
break
# if abs(xp - width // 2) < big_text * 3: # toggle screen size: bugged
# if abs(yp - 700) < big_text // 2:
#
# old_screen_saved = screen
# line_length_idx = (line_length_idx+1)%len(line_lengths)
# line_length = line_lengths[line_length_idx]
#
# height = line_length + info_length # this is equal to 'border line' position
# print(line_length_idx, height)
# screen = pygame.display.set_mode((width, height),
# pygame.RESIZABLE)
# # On the next line, if only part of the window
# # needs to be copied, there's some other options.
# screen.blit(old_screen_saved, (0, 0))
# del old_screen_saved
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE: # esc 키를 누르면 종료
run, meta_run = exit()
break
elif event.key == pygame.K_RETURN:
print('Going to song selection!')
run = False
music_list, music_pointer, song_name = song_selection_screen(screen, clock, stage_speed, offset,
judgement_shown, guide_line_shown,
high_quality_verifying_graphics)
break
if not run:
break
screen.fill(background_color[0])
if creater_mode:
write_text(screen, width // 2, small_text*2, '- This is a creater mode -', small_text, background_color[0],
debug_color)
write_text(screen, width//2, height//8 , 'A rhythm game in pygame', big_text, background_color[0], highlight_text_color)
write_text(screen, option_key_x_level, option_key_y_level,
'Options', big_text, background_color[0],
highlight_text_color)
pygame.draw.rect(screen, highlight_text_color, [width//4 - big_text, option_key_y_level - button_y_offset, button_x_size, button_y_size], 4,8)
write_text(screen, song_selection_key_x_level, song_selection_key_y_level,
'Song selection', big_text, background_color[0],
highlight_text_color)
pygame.draw.rect(screen, highlight_text_color, [width//4 - big_text, song_selection_key_y_level - button_y_offset, button_x_size, button_y_size], 4,8)
# write_text(screen, width // 2, 700,
# 'toggle screen size', small_text, background_color[0],
# highlight_text_color)
write_text(screen, width // 2, height-small_text*4, 'How to play: ', small_text, background_color[0],
highlight_text_color)
write_text(screen, width // 2, height-small_text*2, 'press %s,%s,%s,%s in appropriate timing!'%(guide_keys[0],guide_keys[1],guide_keys[2],guide_keys[3]), small_text, background_color[0],
highlight_text_color)
if mouse_particle_list: # if not empty
#print(len(mouse_particle_list))
current_run_time = pygame.time.get_ticks()
for mouse_particle in mouse_particle_list:
#draw_particle(screen, mouse_particle)
mouse_click_time = mouse_particle[0]
position = mouse_particle[1]
delta = (current_run_time - (mouse_click_time))/1000
if delta >= water_draw_time_mouse:
mouse_particle_list.remove(mouse_particle)
factor = delta / water_draw_time_mouse
radi = calc_drop_radius(factor, mouse_particle_radius)
pygame.draw.circle(screen,effect_color, position, radi, particle_width_mouse)
pygame.display.flip()
clock.tick(main_loop_render_fps)