Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/BasicTextButton.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
29 changes: 23 additions & 6 deletions src/Settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

border_size = 20
topbar_height = 100

Expand All @@ -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")

2 changes: 1 addition & 1 deletion src/TitleScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down