master
parent
ae9ec5389b
commit
e17db93158
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 8.3 KiB |
41
main.py
41
main.py
|
@ -616,23 +616,6 @@ def play_sound():
|
||||||
sound.set_volume(volume)
|
sound.set_volume(volume)
|
||||||
pygame.mixer.Sound.play(sound)
|
pygame.mixer.Sound.play(sound)
|
||||||
|
|
||||||
def render_settings():
|
|
||||||
size_to_y = {"small": 15, "medium": 25, "big": 55}
|
|
||||||
y = size_to_y[settings_data["size"]]
|
|
||||||
|
|
||||||
for setting in enumerate(settings_data):
|
|
||||||
render_text(setting[1], (size[1]-20, y), screen)
|
|
||||||
setting_rect = pygame.Rect(size[0], y, size[2], size[3])
|
|
||||||
setting_hover = setting_rect.collidepoint(pygame.mouse.get_pos())
|
|
||||||
|
|
||||||
if setting_hover and pygame.mouse.get_pressed()[0]:
|
|
||||||
setting_name = setting
|
|
||||||
if setting_name != setting:
|
|
||||||
setting_name = None
|
|
||||||
|
|
||||||
return setting
|
|
||||||
|
|
||||||
y += cons[0]
|
|
||||||
|
|
||||||
def set_hue():
|
def set_hue():
|
||||||
global hue_value
|
global hue_value
|
||||||
|
@ -855,6 +838,13 @@ def data_check(current_mode):
|
||||||
|
|
||||||
return background_image, current_buttons
|
return background_image, current_buttons
|
||||||
|
|
||||||
|
scroll_offset = 0
|
||||||
|
space_between_settings = 5
|
||||||
|
settings_x_position = size[1] - 18
|
||||||
|
settings_y_offset = 5
|
||||||
|
total_settings_height = len(settings_data) * (cons[0] + space_between_settings)
|
||||||
|
max_scroll_offset = max(0, total_settings_height - non_movable_area.height)
|
||||||
|
|
||||||
# Game state
|
# Game state
|
||||||
run = True
|
run = True
|
||||||
current_mode = "menu"
|
current_mode = "menu"
|
||||||
|
@ -963,6 +953,14 @@ while run:
|
||||||
clicked_piece = False
|
clicked_piece = False
|
||||||
can_move = False
|
can_move = False
|
||||||
|
|
||||||
|
elif event.type == pygame.MOUSEBUTTONDOWN and current_mode == "settings":
|
||||||
|
if event.button == 4:
|
||||||
|
scroll_offset -= 20
|
||||||
|
scroll_offset = max(0, scroll_offset)
|
||||||
|
elif event.button == 5:
|
||||||
|
scroll_offset += 20
|
||||||
|
scroll_offset = min(scroll_offset, max_scroll_offset)
|
||||||
|
|
||||||
if current_mode == "game":
|
if current_mode == "game":
|
||||||
if timer_running:
|
if timer_running:
|
||||||
current_time = pygame.time.get_ticks() - timer_start_time
|
current_time = pygame.time.get_ticks() - timer_start_time
|
||||||
|
@ -1052,7 +1050,14 @@ while run:
|
||||||
pygame.time.delay(16)
|
pygame.time.delay(16)
|
||||||
|
|
||||||
if current_mode == "settings":
|
if current_mode == "settings":
|
||||||
render_settings()
|
clipped_rect = pygame.Rect(settings_x_position, non_movable_area.y, size[2], non_movable_area.height)
|
||||||
|
screen.set_clip(clipped_rect)
|
||||||
|
|
||||||
|
for index, setting_name in enumerate(settings_data):
|
||||||
|
y = size[1] - scroll_offset + index * (cons[0] + space_between_settings)
|
||||||
|
render_text(setting_name, (settings_x_position, y - settings_y_offset), screen)
|
||||||
|
|
||||||
|
screen.set_clip(None)
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
194,
|
1094,
|
||||||
"00:00:09",
|
"00:00:11",
|
||||||
"00:00:09",
|
"00:00:11",
|
||||||
13
|
16
|
||||||
],
|
],
|
||||||
"2.png": [
|
"2.png": [
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"puzzle 4x4": [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]], "puzzle 3x3": [[1, 2, 3], [4, 5, 6], [7, 8, 0]], "current 4x4": {"matrix": [[0, 4, 9, 7], [13, 1, 8, 3], [2, 12, 5, 11], [15, 14, 6, 10]], "selected_image": "images/albums/Original images/1.png"}, "current 3x3": {"matrix": [[3, 6, 7], [5, 4, 1], [0, 8, 2]], "selected_image": "/images/albums/Birds/1.png"}}
|
{"puzzle 4x4": [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]], "puzzle 3x3": [[1, 2, 3], [4, 5, 6], [7, 8, 0]], "current 4x4": {"matrix": [[4, 9, 7, 0], [13, 1, 8, 3], [2, 12, 5, 11], [15, 14, 6, 10]], "selected_image": "images/albums/Original images/1.png"}, "current 3x3": {"matrix": [[3, 6, 7], [5, 4, 1], [0, 8, 2]], "selected_image": "/images/albums/Birds/1.png"}}
|
Loading…
Reference in New Issue