elukjanovica 2024-03-12 09:48:38 +02:00
parent 247cd76f1b
commit 40668745ac
6 changed files with 24 additions and 19 deletions

21
main.py
View File

@ -6,6 +6,9 @@ import ctypes
import json
from tkinter import Tk, filedialog
import numpy as np
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
# INITIALIZATION
pygame.init()
@ -123,8 +126,8 @@ if current_size == SIZE_CHOICES[0]:
# --> list[1] (38, 53, 38) - position y for element in spritesheet
# --> list[2] (80, 80, 10) - width of element in settings mode
# --> list[3] (12, 12, 16) - heigth of element
arrow1 = (261, 0, 10, 13)
arrow2 = (274, 0, 10, 13)
arrow1 = (207, 0, 10, 13)
arrow2 = (220, 0, 10, 13)
spaces2 = [4, 5, 2, 5, 60, 42]
spaces3 = [10, 20, 23]
@ -152,9 +155,9 @@ elif current_size == SIZE_CHOICES[1]:
f_line = [135, 38, 100, 16]
s_line = [135, 58, 100, 16]
s_button = [238, 38, 12, 20]
arrow1 = (261, 0, 10, 13)
arrow2 = (274, 0, 10, 13)
spaces2 = [4, 5, 2, 5, 60, 42]
arrow1 = (263, 0, 13, 17)
arrow2 = (280, 0, 13, 17)
spaces2 = [4, 3, 3, 5, 60, 42]
spaces3 = [10, 20, 23]
if current_style == STYLE_CHOICES[2]:
spaces2[1] = 2
@ -303,7 +306,6 @@ class Button:
text_surface = font.render(self.popup_text, True, (0, 0, 0), (255, 255, 225))
text_rect = text_surface.get_rect(center=mouse_pos)
# Increase the size of the popup surface
popup_width = text_rect.width + 14
popup_height = text_rect.height + 14
@ -549,7 +551,9 @@ def load_puzzle():
puzzle_version = settings_data["grid"]
image_path = puzzle_data[f'current {puzzle_version}']['selected_image']
puzzle_image = pygame.image.load(image_path)
path_parts = image_path.split('/')
real_image_path = os.path.abspath(os.path.join(script_dir, *path_parts))
puzzle_image = pygame.image.load(real_image_path)
directions = {"up": [4, 8, 12],
"down": [],
@ -750,7 +754,7 @@ def data_set(setting, value):
settings_data[gui] = value
elif setting == music:
if isinstance(value, str):
settings_data[sound]["version"] = value
settings_data[music]["version"] = value
else:
settings_data[music]["volume"] = value
update_music_volume()
@ -764,6 +768,7 @@ def data_set(setting, value):
with open(SETTINGS_FILE, "w") as settings_file:
json.dump(settings_data, settings_file, indent=2)
def play_music():
music_file = settings_data[music]["version"]
music_file = music_file.replace(" ", "_")

View File

@ -5,10 +5,10 @@
0,
0,
0,
99,
"00:01:11",
"00:00:46",
6
129,
"00:01:24",
"00:00:59",
4
],
"2.png": [
0,

View File

@ -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": [[6, 13, 10, 2], [4, 3, 5, 12], [11, 14, 8, 0], [1, 7, 9, 15]], "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": [[15, 7, 2, 3], [10, 14, 5, 4], [13, 6, 0, 12], [9, 1, 8, 11]], "selected_image": "images/albums/Original images/1.png"}, "current 3x3": {"matrix": [[6, 7, 0], [3, 4, 1], [5, 8, 2]], "selected_image": "/images/albums/Birds/1.png"}}

View File

@ -1,17 +1,17 @@
{
"size": "big",
"style": "dark",
"size": "medium",
"style": "classic",
"grid": "4x4",
"gui color": 0,
"music": {
"on": true,
"volume": 0,
"version": "serenity"
"volume": 1,
"version": "sunny day"
},
"sound": {
"on": true,
"volume": 12,
"version": "wood"
"volume": 4,
"version": "puzzle"
},
"display": "time",
"language": "english",

Binary file not shown.

Binary file not shown.