master
parent
c43e8036f1
commit
6918d12b87
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 270 KiB |
30
main.py
30
main.py
|
@ -51,7 +51,7 @@ current_style = settings_data["style"]
|
||||||
SIZE_CHOICES = ["small", "medium", "big"]
|
SIZE_CHOICES = ["small", "medium", "big"]
|
||||||
STYLE_CHOICES = ["classic", "original", "dark"]
|
STYLE_CHOICES = ["classic", "original", "dark"]
|
||||||
GRID_CHOICES = ["4x4", "3x3"]
|
GRID_CHOICES = ["4x4", "3x3"]
|
||||||
MUSIC_CHOICES = ["funky leap", "serenity", "sunny day"]
|
MUSIC_CHOICES = ["funky leap", "serenity", "sunny day", "epec unf"]
|
||||||
SOUND_CHOICES = ["puzzle", "wood", "metal pipe", "lego breaking"]
|
SOUND_CHOICES = ["puzzle", "wood", "metal pipe", "lego breaking"]
|
||||||
DISPLAY_CHOICES = ["time", "moves", "none"]
|
DISPLAY_CHOICES = ["time", "moves", "none"]
|
||||||
LANGUAGE_CHOICES = ["english", "russian", "latvian"]
|
LANGUAGE_CHOICES = ["english", "russian", "latvian"]
|
||||||
|
@ -125,6 +125,10 @@ if current_size == SIZE_CHOICES[0]:
|
||||||
# --> list[1] (38, 53, 38) - position y for element in spritesheet
|
# --> list[1] (38, 53, 38) - position y for element in spritesheet
|
||||||
# --> list[2] (80, 80, 10) - width of element in settings mode
|
# --> list[2] (80, 80, 10) - width of element in settings mode
|
||||||
# --> list[3] (12, 12, 16) - heigth of element
|
# --> list[3] (12, 12, 16) - heigth of element
|
||||||
|
arrow1 = (261, 0, 10, 13)
|
||||||
|
arrow2 = (274, 0, 10, 13)
|
||||||
|
spaces2 = [4, 5, 2, 5, 60, 42]
|
||||||
|
spaces3 = [10, 20, 23]
|
||||||
|
|
||||||
elif current_size == SIZE_CHOICES[1]:
|
elif current_size == SIZE_CHOICES[1]:
|
||||||
WIDTH, HEIGHT = 202, 216
|
WIDTH, HEIGHT = 202, 216
|
||||||
|
@ -153,6 +157,7 @@ elif current_size == SIZE_CHOICES[1]:
|
||||||
arrow1 = (261, 0, 10, 13)
|
arrow1 = (261, 0, 10, 13)
|
||||||
arrow2 = (274, 0, 10, 13)
|
arrow2 = (274, 0, 10, 13)
|
||||||
spaces2 = [4, 5, 2, 5, 60, 42]
|
spaces2 = [4, 5, 2, 5, 60, 42]
|
||||||
|
spaces3 = [10, 20, 23]
|
||||||
if current_style == STYLE_CHOICES[2]:
|
if current_style == STYLE_CHOICES[2]:
|
||||||
spaces2[1] = 2
|
spaces2[1] = 2
|
||||||
|
|
||||||
|
@ -180,9 +185,10 @@ else:
|
||||||
f_line = [276, 70, 200, 32]
|
f_line = [276, 70, 200, 32]
|
||||||
s_line = [276, 105, 200, 32]
|
s_line = [276, 105, 200, 32]
|
||||||
s_button = [479, 70, 24, 40]
|
s_button = [479, 70, 24, 40]
|
||||||
arrow1 = (261, 0, 10, 13)
|
arrow1 = (485, 0, 21, 32)
|
||||||
arrow2 = (274, 0, 10, 13)
|
arrow2 = (509, 0, 21, 32)
|
||||||
spaces2 = (4, 5, 2, 5, 60, 42)
|
spaces2 = (4, 0, 2, 5, 60, 80)
|
||||||
|
spaces3 = [50, 40, 43]
|
||||||
if current_style == STYLE_CHOICES[2]:
|
if current_style == STYLE_CHOICES[2]:
|
||||||
cons[3] = 8
|
cons[3] = 8
|
||||||
|
|
||||||
|
@ -619,7 +625,6 @@ def update_puzzle_data(completed, sorted, current_time, current_moves, real_time
|
||||||
print("Something went wrong while updating puzzle data")
|
print("Something went wrong while updating puzzle data")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(current_data)
|
|
||||||
initial_chosen, initial_completed, initial_sorted, initial_moves, initial_time, _, _ = current_data
|
initial_chosen, initial_completed, initial_sorted, initial_moves, initial_time, _, _ = current_data
|
||||||
initial_completed = int(completed)
|
initial_completed = int(completed)
|
||||||
initial_sorted = int(sorted)
|
initial_sorted = int(sorted)
|
||||||
|
@ -632,7 +637,6 @@ def update_puzzle_data(completed, sorted, current_time, current_moves, real_time
|
||||||
formatted_time = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
formatted_time = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
||||||
|
|
||||||
current_data = [initial_chosen, initial_completed, initial_sorted, initial_moves, formatted_time, current_time, current_moves]
|
current_data = [initial_chosen, initial_completed, initial_sorted, initial_moves, formatted_time, current_time, current_moves]
|
||||||
print(current_data, path_components)
|
|
||||||
storage["albums"][path_components[0]][path_components[1]] = current_data
|
storage["albums"][path_components[0]][path_components[1]] = current_data
|
||||||
with open(DATA_FILE, 'w') as data_file:
|
with open(DATA_FILE, 'w') as data_file:
|
||||||
data_file.write(json.dumps(storage, indent=3))
|
data_file.write(json.dumps(storage, indent=3))
|
||||||
|
@ -730,6 +734,7 @@ def data_set(setting, value):
|
||||||
|
|
||||||
def play_music():
|
def play_music():
|
||||||
music_file = settings_data[music]["version"]
|
music_file = settings_data[music]["version"]
|
||||||
|
music_file = music_file.replace(" ", "_")
|
||||||
volume = settings_data[music]["volume"]
|
volume = settings_data[music]["volume"]
|
||||||
pygame.mixer.music.load("misc/" + music_file + ".mp3")
|
pygame.mixer.music.load("misc/" + music_file + ".mp3")
|
||||||
pygame.mixer.music.set_volume(volume / 100)
|
pygame.mixer.music.set_volume(volume / 100)
|
||||||
|
@ -737,6 +742,7 @@ def play_music():
|
||||||
|
|
||||||
def play_sound():
|
def play_sound():
|
||||||
sound_file = settings_data[sound]["version"]
|
sound_file = settings_data[sound]["version"]
|
||||||
|
sound_file = sound_file.replace(" ", "_")
|
||||||
volume = settings_data[sound]["volume"]
|
volume = settings_data[sound]["volume"]
|
||||||
current_sound = pygame.mixer.Sound("misc/" + sound_file + ".ogg")
|
current_sound = pygame.mixer.Sound("misc/" + sound_file + ".ogg")
|
||||||
current_sound.set_volume(volume / 100)
|
current_sound.set_volume(volume / 100)
|
||||||
|
@ -836,7 +842,7 @@ def render_text_in_rect(long_text, rect_area):
|
||||||
return text_surfaces, text_rects
|
return text_surfaces, text_rects
|
||||||
|
|
||||||
# Example usage
|
# Example usage
|
||||||
rect_area = non_movable_area
|
rect_area = non_movable_area.copy()
|
||||||
rect_area.x += text_size[1]
|
rect_area.x += text_size[1]
|
||||||
rect_area.width -= text_size[1]
|
rect_area.width -= text_size[1]
|
||||||
long_text = (
|
long_text = (
|
||||||
|
@ -930,7 +936,6 @@ def load_data():
|
||||||
current_timer_text = timer_text
|
current_timer_text = timer_text
|
||||||
displayed_current_moves = current_data[6]
|
displayed_current_moves = current_data[6]
|
||||||
current_moves = 0
|
current_moves = 0
|
||||||
print("loaded from -", current_data, path_components)
|
|
||||||
|
|
||||||
return completed, not_shuffled, timer_text, current_timer_text, displayed_current_moves, current_moves
|
return completed, not_shuffled, timer_text, current_timer_text, displayed_current_moves, current_moves
|
||||||
|
|
||||||
|
@ -1200,7 +1205,6 @@ while run:
|
||||||
if settings_data[sound]["on"] and moved is not None:
|
if settings_data[sound]["on"] and moved is not None:
|
||||||
current_moves += 1
|
current_moves += 1
|
||||||
user_win = True
|
user_win = True
|
||||||
print("clicked:", current_moves)
|
|
||||||
pygame.mixer.Sound.play(current_sound)
|
pygame.mixer.Sound.play(current_sound)
|
||||||
|
|
||||||
if pressed_button == hint_button:
|
if pressed_button == hint_button:
|
||||||
|
@ -1301,16 +1305,16 @@ while run:
|
||||||
setting = setting_name
|
setting = setting_name
|
||||||
elif not dragging:
|
elif not dragging:
|
||||||
active_sliders[music] = False
|
active_sliders[music] = False
|
||||||
music_choosing = arrows((settings_x_position // 2 - spaces[3], y + spaces[0]+24), setting_name, value2, MUSIC_CHOICES, event_list)
|
music_choosing = arrows((settings_x_position // 2 - spaces[3], y + spaces[0]+spaces3[2]), setting_name, value2, MUSIC_CHOICES, event_list)
|
||||||
music_choosing[0].update(mouse_pos)
|
music_choosing[0].update(mouse_pos)
|
||||||
music_choosing[2].update(mouse_pos)
|
music_choosing[2].update(mouse_pos)
|
||||||
music_choosing[0].draw(screen)
|
music_choosing[0].draw(screen)
|
||||||
music_choosing[2].draw(screen)
|
music_choosing[2].draw(screen)
|
||||||
active_selects["music_version"] = True
|
active_selects["music_version"] = True
|
||||||
elif setting_name == sound:
|
elif setting_name == sound:
|
||||||
render_settings_text(setting_name.upper(),(settings_x_position // 2 + spaces[4], y+20), screen, value)
|
render_settings_text(setting_name.upper(),(settings_x_position // 2 + spaces[4], y+spaces3[1]), screen, value)
|
||||||
y += spaces2[5]
|
y += spaces2[5]
|
||||||
sound_volume_slider = slider((settings_x_position // 2 - spaces[3], y-10), 100, value, active_sliders, setting_name)
|
sound_volume_slider = slider((settings_x_position // 2 - spaces[3], y-spaces3[0]), 100, value, active_sliders, setting_name)
|
||||||
for slider_part in sound_volume_slider:
|
for slider_part in sound_volume_slider:
|
||||||
slider_part.draw(screen)
|
slider_part.draw(screen)
|
||||||
if dragging and sound_volume_slider[2].rect.collidepoint(mouse_pos):
|
if dragging and sound_volume_slider[2].rect.collidepoint(mouse_pos):
|
||||||
|
@ -1330,6 +1334,8 @@ while run:
|
||||||
if current_mode == "info":
|
if current_mode == "info":
|
||||||
for text_surface, text_rect in zip(text_surfaces, text_rects):
|
for text_surface, text_rect in zip(text_surfaces, text_rects):
|
||||||
screen.blit(text_surface, text_rect)
|
screen.blit(text_surface, text_rect)
|
||||||
|
if current_mode == "stats":
|
||||||
|
print("Currently under maintenance")
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
85,
|
111,
|
||||||
"00:00:40",
|
"00:01:00",
|
||||||
"00:00:40",
|
"00:01:00",
|
||||||
0
|
3
|
||||||
],
|
],
|
||||||
"3.png": [
|
"3.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": [[10, 2, 5, 12], [13, 4, 3, 15], [6, 14, 8, 0], [11, 1, 7, 9]], "selected_image": "images/albums/Original images/2.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": [[6, 13, 10, 2], [4, 3, 5, 12], [11, 14, 8, 15], [1, 7, 9, 0]], "selected_image": "images/albums/Original images/2.png"}, "current 3x3": {"matrix": [[3, 6, 7], [5, 4, 1], [0, 8, 2]], "selected_image": "/images/albums/Birds/1.png"}}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"size": "medium",
|
"size": "big",
|
||||||
"style": "classic",
|
"style": "dark",
|
||||||
"grid": "4x4",
|
"grid": "4x4",
|
||||||
"gui color": 0,
|
"gui color": 0,
|
||||||
"music": {
|
"music": {
|
||||||
|
|
Loading…
Reference in New Issue