diff --git a/src/BasicTextButton.py b/src/BasicTextButton.py index aa15b2a..e25c371 100644 --- a/src/BasicTextButton.py +++ b/src/BasicTextButton.py @@ -1,15 +1,17 @@ +from typing import Set from Button import Button from pygame import Vector2 from Text import Text, ALIGN_CENTER +import Settings class BasicTextButton(Button): def __init__(self, text = "", pos = Vector2(0,0), flag = None): self.text = text if flag: - super().__init__("images/buttonframe2.png","images/buttonframe2_hover.png","images/buttonframe2_down.png") + super().__init__(Settings.f2_path,Settings.f2_hover_path,Settings.f2_down_path) self.text_object = Text(text, 25, align = ALIGN_CENTER, bold = True, italic=True) else: - super().__init__("images/buttonframe.png","images/buttonframe_hover.png","images/buttonframe_down.png") + super().__init__(Settings.f_path, Settings.f_hover_path, Settings.f_down_path) self.text_object = Text(text, 36, align = ALIGN_CENTER, bold = True, italic=True) def update(self, delta_time = 0): diff --git a/src/Settings.py b/src/Settings.py index 7c4afbb..28ec2d0 100644 --- a/src/Settings.py +++ b/src/Settings.py @@ -1,4 +1,3 @@ - border_size = 20 topbar_height = 100 @@ -13,9 +12,27 @@ Ddisplay_width=border_size*2+Dboard_size[0]*cell_size[0] Ddisplay_height=border_size*2+Dboard_size[1]*cell_size[1] + title = "Snake Game" -icon_path = "images/icon.png" -font_style = "fonts/arial.ttf" -save_dir = "data" -save_state_path = "data/gamescene.dat" -save_rankings_path = "data/score.dat" + + +import os +from pathlib import Path + +base = str(Path(__file__).absolute().parent.parent) +icon_path = os.path.join(base, "images/icon.png") +font_style = os.path.join(base, "fonts/arial.ttf") +save_dir = os.path.join(base, "data") +save_state_path = os.path.join(base, "data/gamescene.dat") +save_rankings_path = os.path.join(base, "data/score.dat") + +bg_path = os.path.join(base, "images/titlescene/bg.png") + +f_path = os.path.join(base, "images/buttonframe.png") +f_hover_path = os.path.join(base, "images/buttonframe_hover.png") +f_down_path = os.path.join(base, "images/buttonframe_down.png") + +f2_path = os.path.join(base, "images/buttonframe2.png") +f2_hover_path = os.path.join(base, "images/buttonframe2_hover.png") +f2_down_path = os.path.join(base, "images/buttonframe2_down.png") + diff --git a/src/TitleScene.py b/src/TitleScene.py index c8ff389..3e3318e 100644 --- a/src/TitleScene.py +++ b/src/TitleScene.py @@ -16,7 +16,7 @@ class TitleScene: def __init__(self, saved = False): - self.bg = GameObject("images/titlescene/bg.png") + self.bg = GameObject(Settings.bg_path) self.bg.set_size(Settings.display_width, Settings.display_height) self.saved = saved