mirror of
https://github.com/csd4ni3l/notifplayground.git
synced 2025-11-05 05:58:17 +01:00
Add demo GIF, Hot Air Baloon, add a way to customize notification timeout, rows and columns, make main menu buttons smaller, fix tetris not updating info label after restart
This commit is contained in:
@@ -2,4 +2,7 @@ Games made inside notifications! Currently includes Flappy Bird, Maze, Pong, Spa
|
|||||||
|
|
||||||
Some parts of Tetris are based on my other project, ShatterStack, which is a Block Blast style game.
|
Some parts of Tetris are based on my other project, ShatterStack, which is a Block Blast style game.
|
||||||
|
|
||||||
The whole thing is just completely unusable on Windows due to Windows having such a high animation delay for notifications. Also, on Windows, only the WPS test works, due to Windows only allowing up to 141 characters in a notification. I only tested on Arch Linux with Hyprland + ML4W dotfiles, so your mileage may differ.
|
The whole thing is just completely unusable on Windows due to Windows having such a high animation delay for notifications. Also, on Windows, only the WPS test works normally, for other games you can try to lower notification rows and columns but i dont guarantee that anything is going to work. I only tested on Arch Linux with Hyprland + ML4W dotfiles, so your mileage may differ.
|
||||||
|
|
||||||
|
If you can't try it out, Snake, for example looks like this:
|
||||||
|

|
||||||
@@ -2,8 +2,6 @@ import arcade, arcade.gui, time, random, os, json
|
|||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
def __init__(self, pypresence_client):
|
def __init__(self, pypresence_client):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -18,8 +16,11 @@ class Game(arcade.gui.UIView):
|
|||||||
self.should_jump = False
|
self.should_jump = False
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
self.pipes = []
|
self.pipes = []
|
||||||
self.bird_position = [0, int(ROWS / 2)]
|
self.bird_position = [0, int(self.settings.get("notification_rows", 20) / 2)]
|
||||||
self.cycles = 0
|
self.cycles = 0
|
||||||
|
|
||||||
if not os.path.exists("data.json"):
|
if not os.path.exists("data.json"):
|
||||||
@@ -38,25 +39,25 @@ class Game(arcade.gui.UIView):
|
|||||||
if pipe_type == "bottom":
|
if pipe_type == "bottom":
|
||||||
bottom = 0
|
bottom = 0
|
||||||
else:
|
else:
|
||||||
bottom = ROWS - size
|
bottom = self.settings.get("notification_rows", 20) - size
|
||||||
|
|
||||||
left = COLS
|
left = self.settings.get("notification_cols", 25)
|
||||||
|
|
||||||
for pipe_y in range(bottom, bottom + size):
|
for pipe_y in range(bottom, bottom + size):
|
||||||
self.pipes.append([left, pipe_y])
|
self.pipes.append([left, pipe_y])
|
||||||
|
|
||||||
def create_pipe(self):
|
def create_pipe(self):
|
||||||
gap_size = ROWS // 5
|
gap_size = self.settings.get("notification_rows", 20) // 5
|
||||||
gap_start = random.randint(1, ROWS - gap_size - 1)
|
gap_start = random.randint(1, self.settings.get("notification_rows", 20) - gap_size - 1)
|
||||||
|
|
||||||
bottom_height = gap_start
|
bottom_height = gap_start
|
||||||
self.create_pipe_part(bottom_height, "bottom")
|
self.create_pipe_part(bottom_height, "bottom")
|
||||||
|
|
||||||
top_height = ROWS - (gap_start + gap_size)
|
top_height = self.settings.get("notification_rows", 20) - (gap_start + gap_size)
|
||||||
self.create_pipe_part(top_height, "top")
|
self.create_pipe_part(top_height, "top")
|
||||||
|
|
||||||
def on_update(self, delta_time):
|
def on_update(self, delta_time):
|
||||||
if self.running and time.perf_counter() - self.last_update_time >= 0.4:
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
self.pipes = [[pipe_x - 1, pipe_y] for pipe_x, pipe_y in self.pipes if pipe_x - 1 >= 0]
|
self.pipes = [[pipe_x - 1, pipe_y] for pipe_x, pipe_y in self.pipes if pipe_x - 1 >= 0]
|
||||||
|
|
||||||
if self.should_jump:
|
if self.should_jump:
|
||||||
@@ -67,7 +68,7 @@ class Game(arcade.gui.UIView):
|
|||||||
jumped = False
|
jumped = False
|
||||||
self.bird_position[1] += 2
|
self.bird_position[1] += 2
|
||||||
|
|
||||||
if self.bird_position in self.pipes or self.bird_position[1] >= ROWS or self.bird_position[1] <= 0:
|
if self.bird_position in self.pipes or self.bird_position[1] >= self.settings.get("notification_rows", 20) or self.bird_position[1] <= 0:
|
||||||
self.info_label.text = "Game Over.\nPress r to restart"
|
self.info_label.text = "Game Over.\nPress r to restart"
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
@@ -87,8 +88,8 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
for y in range(ROWS):
|
for y in range(self.settings.get("notification_rows", 20)):
|
||||||
for x in range(COLS):
|
for x in range(self.settings.get("notification_cols", 25)):
|
||||||
if [x, y] in self.pipes:
|
if [x, y] in self.pipes:
|
||||||
text += "|"
|
text += "|"
|
||||||
elif [x, y] == self.bird_position:
|
elif [x, y] == self.bird_position:
|
||||||
@@ -135,7 +136,7 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.bird_position = [0, int(ROWS / 2)]
|
self.bird_position = [0, int(self.settings.get("notification_rows", 20) / 2)]
|
||||||
self.cycles = 0
|
self.cycles = 0
|
||||||
self.should_jump = False
|
self.should_jump = False
|
||||||
|
|
||||||
|
|||||||
137
game/hot_air_baloon.py
Normal file
137
game/hot_air_baloon.py
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
import arcade, arcade.gui, time, random, os, json
|
||||||
|
|
||||||
|
from plyer import notification
|
||||||
|
|
||||||
|
class Game(arcade.gui.UIView):
|
||||||
|
def __init__(self, pypresence_client):
|
||||||
|
super().__init__()
|
||||||
|
self.pypresence_client = pypresence_client
|
||||||
|
self.pypresence_client.update(state="Playing Hot Air Baloon inside notifications!")
|
||||||
|
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout(size_hint=(1, 1)))
|
||||||
|
self.info_label = self.anchor.add(arcade.gui.UILabel("Use arrow keys or WASD to move\nYou can see the game inside notifications.", font_size=24, multiline=True))
|
||||||
|
|
||||||
|
self.running = True
|
||||||
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
|
self.spikes = []
|
||||||
|
self.points = []
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
|
self.baloon_position = arcade.math.Vec2(0, self.settings.get("notification_rows", 20) - 1)
|
||||||
|
self.baloon_direction = arcade.math.Vec2()
|
||||||
|
|
||||||
|
if not os.path.exists("data.json"):
|
||||||
|
self.data = {}
|
||||||
|
else:
|
||||||
|
with open("data.json", "r") as file:
|
||||||
|
self.data = json.load(file)
|
||||||
|
if "hot_air_baloon" not in self.data:
|
||||||
|
self.data["hot_air_baloon"] = {"high_score": 0}
|
||||||
|
|
||||||
|
self.score = 0
|
||||||
|
self.high_score = self.data["hot_air_baloon"]["high_score"]
|
||||||
|
|
||||||
|
self.last_spawn_time = time.perf_counter()
|
||||||
|
self.spawn_interval = 0.8
|
||||||
|
self.difficulty = 0.4
|
||||||
|
self.pattern_cooldown = 0
|
||||||
|
self.pattern = []
|
||||||
|
|
||||||
|
def spawn_items(self):
|
||||||
|
if self.pattern_cooldown <= 0:
|
||||||
|
pattern_type = random.choice(["wave", "gap", "scatter"])
|
||||||
|
|
||||||
|
if pattern_type == "wave":
|
||||||
|
base = random.randint(0, self.settings.get("notification_cols", 25) - 4)
|
||||||
|
self.pattern = [(base + i, 0) for i in range(3)]
|
||||||
|
elif pattern_type == "gap":
|
||||||
|
gap = random.randint(1, self.settings.get("notification_cols", 25) - 2)
|
||||||
|
self.pattern = [(x, 0) for x in range(self.settings.get("notification_cols", 25)) if x != gap]
|
||||||
|
else:
|
||||||
|
self.pattern = [(random.randint(0, self.settings.get("notification_cols", 25) - 1), 0) for _ in range(random.randint(2, 4))]
|
||||||
|
|
||||||
|
self.pattern_cooldown = random.randint(3, 6)
|
||||||
|
|
||||||
|
for pos in self.pattern:
|
||||||
|
if random.random() < self.difficulty:
|
||||||
|
self.spikes.append(pos)
|
||||||
|
else:
|
||||||
|
self.points.append(pos)
|
||||||
|
|
||||||
|
self.pattern_cooldown -= 1
|
||||||
|
|
||||||
|
def on_show_view(self):
|
||||||
|
super().on_show_view()
|
||||||
|
self.spawn_items()
|
||||||
|
|
||||||
|
def on_update(self, delta_time):
|
||||||
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
|
self.baloon_position += self.baloon_direction
|
||||||
|
self.baloon_direction = arcade.math.Vec2()
|
||||||
|
|
||||||
|
self.baloon_position = arcade.math.Vec2(max(0, min(self.settings.get("notification_cols", 25) - 1, self.baloon_position.x)), max(0, min(self.settings.get("notification_rows", 20) - 1, self.baloon_position.y)))
|
||||||
|
|
||||||
|
self.spikes = [(x, y + 1) for x, y in self.spikes if y < self.settings.get("notification_rows", 20)]
|
||||||
|
self.points = [(x, y + 1) for x, y in self.points if y < self.settings.get("notification_rows", 20)]
|
||||||
|
|
||||||
|
if (self.baloon_position.x, self.baloon_position.y) in self.points:
|
||||||
|
self.score += 1
|
||||||
|
self.points.remove((self.baloon_position.x, self.baloon_position.y))
|
||||||
|
self.difficulty = min(0.9, self.difficulty + 0.01)
|
||||||
|
|
||||||
|
elif (self.baloon_position.x, self.baloon_position.y) in self.spikes:
|
||||||
|
self.running = False
|
||||||
|
self.info_label.text = f"Game Over! Score: {self.score}\nPress r to restart"
|
||||||
|
|
||||||
|
if time.perf_counter() - self.last_spawn_time >= self.spawn_interval:
|
||||||
|
self.last_spawn_time = time.perf_counter()
|
||||||
|
self.spawn_items()
|
||||||
|
|
||||||
|
text = ""
|
||||||
|
for y in range(self.settings.get("notification_rows", 20)):
|
||||||
|
for x in range(self.settings.get("notification_cols", 25)):
|
||||||
|
if arcade.math.Vec2(x, y) == self.baloon_position:
|
||||||
|
text += "O"
|
||||||
|
elif (x, y) in self.spikes:
|
||||||
|
text += "E"
|
||||||
|
elif (x, y) in self.points:
|
||||||
|
text += "o"
|
||||||
|
else:
|
||||||
|
text += "_"
|
||||||
|
text += "\n"
|
||||||
|
|
||||||
|
notification.notify(
|
||||||
|
title=f"Hot Air Baloon | Score: {self.score} High Score: {self.high_score}",
|
||||||
|
message=text
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_key_press(self, symbol, modifiers):
|
||||||
|
if symbol == arcade.key.ESCAPE:
|
||||||
|
if self.score > self.high_score:
|
||||||
|
self.high_score = self.score
|
||||||
|
self.data["hot_air_baloon"]["high_score"] = self.high_score
|
||||||
|
with open("data.json", "w") as file:
|
||||||
|
file.write(json.dumps(self.data, indent=4))
|
||||||
|
from menus.main import Main
|
||||||
|
self.window.show_view(Main(self.pypresence_client))
|
||||||
|
elif symbol == arcade.key.R and not self.running:
|
||||||
|
self.info_label.text = "Use arrow keys or WASD to move\nThe game is shown inside notifications."
|
||||||
|
self.spikes.clear()
|
||||||
|
self.points.clear()
|
||||||
|
self.baloon_position = arcade.math.Vec2(0, self.settings.get("notification_rows", 20) - 1)
|
||||||
|
self.baloon_direction = arcade.math.Vec2()
|
||||||
|
self.score = 0
|
||||||
|
self.running = True
|
||||||
|
self.difficulty = 0.4
|
||||||
|
elif symbol in (arcade.key.LEFT, arcade.key.A):
|
||||||
|
self.baloon_direction = arcade.math.Vec2(-1, 0)
|
||||||
|
elif symbol in (arcade.key.RIGHT, arcade.key.D):
|
||||||
|
self.baloon_direction = arcade.math.Vec2(1, 0)
|
||||||
|
elif symbol in (arcade.key.UP, arcade.key.W):
|
||||||
|
self.baloon_direction = arcade.math.Vec2(0, -1)
|
||||||
|
elif symbol in (arcade.key.DOWN, arcade.key.S):
|
||||||
|
self.baloon_direction = arcade.math.Vec2(0, 1)
|
||||||
11
game/maze.py
11
game/maze.py
@@ -1,9 +1,7 @@
|
|||||||
import arcade, arcade.gui, time, random
|
import arcade, arcade.gui, time, random, json
|
||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
def __init__(self, pypresence_client):
|
def __init__(self, pypresence_client):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -14,6 +12,9 @@ class Game(arcade.gui.UIView):
|
|||||||
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout(size_hint=(1, 1)))
|
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout(size_hint=(1, 1)))
|
||||||
self.info_label = self.anchor.add(arcade.gui.UILabel("Use arrow keys or WASD to move.\nMaze is shown in notifications.", font_size=24, multiline=True))
|
self.info_label = self.anchor.add(arcade.gui.UILabel("Use arrow keys or WASD to move.\nMaze is shown in notifications.", font_size=24, multiline=True))
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
self.running = True
|
self.running = True
|
||||||
self.time_start = time.perf_counter()
|
self.time_start = time.perf_counter()
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.direction = arcade.math.Vec2()
|
self.direction = arcade.math.Vec2()
|
||||||
|
|
||||||
def on_show_view(self):
|
def on_show_view(self):
|
||||||
self.maze, start_x, start_y = self.generate_maze(int(COLS / 2), int(ROWS / 2))
|
self.maze, start_x, start_y = self.generate_maze(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 2))
|
||||||
self.current_position = arcade.math.Vec2(start_x, start_y)
|
self.current_position = arcade.math.Vec2(start_x, start_y)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
self.info_label.text = "Use arrow keys or WASD to move.\nMaze is shown in notifications."
|
self.info_label.text = "Use arrow keys or WASD to move.\nMaze is shown in notifications."
|
||||||
|
|
||||||
self.maze, start_x, start_y = self.generate_maze(int(COLS / 3), int(ROWS / 3))
|
self.maze, start_x, start_y = self.generate_maze(int(self.settings.get("notification_cols", 25) / 3), int(self.settings.get("notification_rows", 20) / 3))
|
||||||
self.current_position = arcade.math.Vec2(start_x, start_y)
|
self.current_position = arcade.math.Vec2(start_x, start_y)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
|||||||
39
game/pong.py
39
game/pong.py
@@ -2,8 +2,6 @@ import arcade, arcade.gui, time, random, os, json
|
|||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
def __init__(self, pypresence_client):
|
def __init__(self, pypresence_client):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -17,14 +15,17 @@ class Game(arcade.gui.UIView):
|
|||||||
self.running = True
|
self.running = True
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.ball_position = arcade.math.Vec2(int(COLS / 2), int(ROWS / 4))
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
|
self.ball_position = arcade.math.Vec2(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 4))
|
||||||
|
|
||||||
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
||||||
|
|
||||||
self.paddle_a_position = arcade.math.Vec2(0, int(ROWS / 4))
|
self.paddle_a_position = arcade.math.Vec2(0, int(self.settings.get("notification_rows", 20) / 4))
|
||||||
self.paddle_a_direction = 0
|
self.paddle_a_direction = 0
|
||||||
|
|
||||||
self.paddle_b_position = arcade.math.Vec2(COLS - 1, int(ROWS / 4))
|
self.paddle_b_position = arcade.math.Vec2(self.settings.get("notification_cols", 25) - 1, int(self.settings.get("notification_rows", 20) / 4))
|
||||||
self.paddle_b_direction = 0
|
self.paddle_b_direction = 0
|
||||||
|
|
||||||
self.score_a = 0
|
self.score_a = 0
|
||||||
@@ -42,7 +43,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.high_score = self.data["pong"]["high_score"]
|
self.high_score = self.data["pong"]["high_score"]
|
||||||
|
|
||||||
def on_update(self, delta_time):
|
def on_update(self, delta_time):
|
||||||
if self.running and time.perf_counter() - self.last_update_time >= 0.4:
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.ball_position += self.ball_direction
|
self.ball_position += self.ball_direction
|
||||||
@@ -68,34 +69,34 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if self.ball_position.x <= 0:
|
if self.ball_position.x <= 0:
|
||||||
if self.ball_position.y <= 0 or self.ball_position.y >= int(ROWS / 2):
|
if self.ball_position.y <= 0 or self.ball_position.y >= int(self.settings.get("notification_rows", 20) / 2):
|
||||||
self.ball_position = arcade.math.Vec2(0, self.ball_position.y)
|
self.ball_position = arcade.math.Vec2(0, self.ball_position.y)
|
||||||
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(1, 0))
|
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(1, 0))
|
||||||
else:
|
else:
|
||||||
self.score_b += 1
|
self.score_b += 1
|
||||||
self.ball_position = arcade.math.Vec2(int(COLS / 2), int(ROWS / 4))
|
self.ball_position = arcade.math.Vec2(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 4))
|
||||||
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
||||||
|
|
||||||
elif self.ball_position.x >= COLS:
|
elif self.ball_position.x >= self.settings.get("notification_cols", 25):
|
||||||
if self.ball_position.y <= 0 or self.ball_position.y >= int(ROWS / 2):
|
if self.ball_position.y <= 0 or self.ball_position.y >= int(self.settings.get("notification_rows", 20) / 2):
|
||||||
self.ball_position = arcade.math.Vec2(COLS, self.ball_position.y)
|
self.ball_position = arcade.math.Vec2(self.settings.get("notification_cols", 25), self.ball_position.y)
|
||||||
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(-1, 0))
|
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(-1, 0))
|
||||||
else:
|
else:
|
||||||
self.score_a += 1
|
self.score_a += 1
|
||||||
self.ball_position = arcade.math.Vec2(int(COLS / 2), int(ROWS / 4))
|
self.ball_position = arcade.math.Vec2(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 4))
|
||||||
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
||||||
|
|
||||||
if self.ball_position.y <= 0:
|
if self.ball_position.y <= 0:
|
||||||
self.ball_position = arcade.math.Vec2(self.ball_position.x, 0)
|
self.ball_position = arcade.math.Vec2(self.ball_position.x, 0)
|
||||||
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(0, 1))
|
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(0, 1))
|
||||||
elif self.ball_position.y >= int(ROWS / 2):
|
elif self.ball_position.y >= int(self.settings.get("notification_rows", 20) / 2):
|
||||||
self.ball_position = arcade.math.Vec2(self.ball_position.x, int(ROWS / 2))
|
self.ball_position = arcade.math.Vec2(self.ball_position.x, int(self.settings.get("notification_rows", 20) / 2))
|
||||||
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(0, -1))
|
self.ball_direction = self.ball_direction.reflect(arcade.math.Vec2(0, -1))
|
||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
for y in range(int(ROWS / 2)):
|
for y in range(int(self.settings.get("notification_rows", 20) / 2)):
|
||||||
for x in range(COLS):
|
for x in range(self.settings.get("notification_cols", 25)):
|
||||||
if (x, y) == self.paddle_a_position or (x, y) == self.paddle_b_position:
|
if (x, y) == self.paddle_a_position or (x, y) == self.paddle_b_position:
|
||||||
text += "|"
|
text += "|"
|
||||||
elif self.ball_position == (x, y):
|
elif self.ball_position == (x, y):
|
||||||
@@ -126,12 +127,12 @@ class Game(arcade.gui.UIView):
|
|||||||
self.window.show_view(Main(self.pypresence_client))
|
self.window.show_view(Main(self.pypresence_client))
|
||||||
elif symbol == arcade.key.R and not self.running:
|
elif symbol == arcade.key.R and not self.running:
|
||||||
self.paddle_a_direction = 0
|
self.paddle_a_direction = 0
|
||||||
self.paddle_a_position = arcade.math.Vec2(0, int(ROWS / 4))
|
self.paddle_a_position = arcade.math.Vec2(0, int(self.settings.get("notification_rows", 20) / 4))
|
||||||
|
|
||||||
self.paddle_b_direction = 0
|
self.paddle_b_direction = 0
|
||||||
self.paddle_b_position = arcade.math.Vec2(COLS - 1, int(ROWS / 4))
|
self.paddle_b_position = arcade.math.Vec2(self.settings.get("notification_cols", 25) - 1, int(self.settings.get("notification_rows", 20) / 4))
|
||||||
|
|
||||||
self.ball_position = arcade.math.Vec2(int(COLS / 2), int(ROWS / 4))
|
self.ball_position = arcade.math.Vec2(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 4))
|
||||||
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
self.ball_direction = arcade.math.Vec2(*random.choice([(-1, 1), (1, 1), (-1, 1), (-1, -1)]))
|
||||||
|
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import arcade, arcade.gui, time, random, os, json
|
|||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
def __init__(self, pypresence_client):
|
def __init__(self, pypresence_client):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -18,9 +16,12 @@ class Game(arcade.gui.UIView):
|
|||||||
self.running = True
|
self.running = True
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.snake = [(int(COLS / 2), int(ROWS / 2))]
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
|
self.snake = [(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 2))]
|
||||||
self.foods = []
|
self.foods = []
|
||||||
|
|
||||||
if not os.path.exists("data.json"):
|
if not os.path.exists("data.json"):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
else:
|
else:
|
||||||
@@ -35,13 +36,13 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
def spawn_food(self):
|
def spawn_food(self):
|
||||||
while True:
|
while True:
|
||||||
x, y = (random.randint(0, COLS), random.randint(0, ROWS))
|
x, y = (random.randint(0, self.settings.get("notification_cols", 25)), random.randint(0, self.settings.get("notification_rows", 20)))
|
||||||
|
|
||||||
if not (x, y) in self.snake:
|
if not (x, y) in self.snake:
|
||||||
return (x, y)
|
return (x, y)
|
||||||
|
|
||||||
def on_update(self, dt):
|
def on_update(self, dt):
|
||||||
if self.running and time.perf_counter() - self.last_update_time >= 0.4:
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
head_x, head_y = self.snake[0]
|
head_x, head_y = self.snake[0]
|
||||||
@@ -55,7 +56,7 @@ class Game(arcade.gui.UIView):
|
|||||||
elif self.direction == "down":
|
elif self.direction == "down":
|
||||||
new_head = (head_x, head_y + 1)
|
new_head = (head_x, head_y + 1)
|
||||||
|
|
||||||
if new_head in self.snake or not (0 <= new_head[0] < COLS and 0 <= new_head[1] < ROWS):
|
if new_head in self.snake or not (0 <= new_head[0] < self.settings.get("notification_cols", 25) and 0 <= new_head[1] < self.settings.get("notification_rows", 20)):
|
||||||
self.info_label.text = "Game Over.\nPress r to restart"
|
self.info_label.text = "Game Over.\nPress r to restart"
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
@@ -77,8 +78,8 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
for y in range(ROWS):
|
for y in range(self.settings.get("notification_rows", 20)):
|
||||||
for x in range(COLS):
|
for x in range(self.settings.get("notification_cols", 25)):
|
||||||
if (x, y) == self.snake[0]:
|
if (x, y) == self.snake[0]:
|
||||||
text += "H"
|
text += "H"
|
||||||
elif (x, y) in self.snake[1:]:
|
elif (x, y) in self.snake[1:]:
|
||||||
@@ -116,7 +117,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.info_label.text = "Press keys inside this window to interact with the game.\nYou can see the game inside notifications."
|
self.info_label.text = "Press keys inside this window to interact with the game.\nYou can see the game inside notifications."
|
||||||
self.info_label.fit_content()
|
self.info_label.fit_content()
|
||||||
|
|
||||||
self.snake = [(int(COLS / 2), int(ROWS / 2))]
|
self.snake = [(int(self.settings.get("notification_cols", 25) / 2), int(self.settings.get("notification_rows", 20) / 2))]
|
||||||
self.foods = [self.spawn_food() for _ in range(3)]
|
self.foods = [self.spawn_food() for _ in range(3)]
|
||||||
self.running = True
|
self.running = True
|
||||||
elif symbol == arcade.key.ESCAPE:
|
elif symbol == arcade.key.ESCAPE:
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import arcade, arcade.gui, time, random, os, json
|
|||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
def __init__(self, pypresence_client):
|
def __init__(self, pypresence_client):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -17,6 +15,9 @@ class Game(arcade.gui.UIView):
|
|||||||
self.running = True
|
self.running = True
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
if not os.path.exists("data.json"):
|
if not os.path.exists("data.json"):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
else:
|
else:
|
||||||
@@ -29,7 +30,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.high_score = self.data["space_invaders"]["high_score"]
|
self.high_score = self.data["space_invaders"]["high_score"]
|
||||||
self.score = 0
|
self.score = 0
|
||||||
|
|
||||||
self.ship_position = arcade.math.Vec2(0, int(ROWS / 2) - 1)
|
self.ship_position = arcade.math.Vec2(0, int(self.settings.get("notification_rows", 20) / 2) - 1)
|
||||||
|
|
||||||
self.ship_direction = arcade.math.Vec2(0, 0)
|
self.ship_direction = arcade.math.Vec2(0, 0)
|
||||||
|
|
||||||
@@ -40,15 +41,15 @@ class Game(arcade.gui.UIView):
|
|||||||
self.last_enemy_shoot = time.perf_counter()
|
self.last_enemy_shoot = time.perf_counter()
|
||||||
|
|
||||||
def summon_enemies(self):
|
def summon_enemies(self):
|
||||||
self.enemies = [[x, y] for x in range(int(COLS)) for y in range(int(int(ROWS / 2) / 5))]
|
self.enemies = [[x, y] for x in range(int(self.settings.get("notification_cols", 25))) for y in range(int(int(self.settings.get("notification_rows", 20) / 2) / 5))]
|
||||||
|
|
||||||
def update_enemies(self):
|
def update_enemies(self):
|
||||||
columns = list(range(COLS))
|
columns = list(range(self.settings.get("notification_cols", 25)))
|
||||||
random.shuffle(columns)
|
random.shuffle(columns)
|
||||||
|
|
||||||
for x in columns:
|
for x in columns:
|
||||||
max_y = -99999
|
max_y = -99999
|
||||||
for y in range(int(int(ROWS / 2) / 3)):
|
for y in range(int(int(self.settings.get("notification_rows", 20) / 2) / 3)):
|
||||||
if not [x, y] in self.enemies:
|
if not [x, y] in self.enemies:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -65,15 +66,15 @@ class Game(arcade.gui.UIView):
|
|||||||
self.summon_enemies()
|
self.summon_enemies()
|
||||||
|
|
||||||
def on_update(self, delta_time):
|
def on_update(self, delta_time):
|
||||||
if self.running and time.perf_counter() - self.last_update_time >= 0.4:
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.ship_position += self.ship_direction
|
self.ship_position += self.ship_direction
|
||||||
|
|
||||||
if self.ship_position.x < 0:
|
if self.ship_position.x < 0:
|
||||||
self.ship_position = arcade.math.Vec2(0, self.ship_position.y)
|
self.ship_position = arcade.math.Vec2(0, self.ship_position.y)
|
||||||
elif self.ship_position.x > COLS:
|
elif self.ship_position.x > self.settings.get("notification_cols", 25):
|
||||||
self.ship_position = arcade.math.Vec2(COLS, self.ship_position.y)
|
self.ship_position = arcade.math.Vec2(self.settings.get("notification_cols", 25), self.ship_position.y)
|
||||||
|
|
||||||
self.ship_direction = arcade.math.Vec2(0, 0)
|
self.ship_direction = arcade.math.Vec2(0, 0)
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ class Game(arcade.gui.UIView):
|
|||||||
bullets_to_remove.add(b)
|
bullets_to_remove.add(b)
|
||||||
|
|
||||||
for b in new_enemy:
|
for b in new_enemy:
|
||||||
if b[1] > int(ROWS / 2):
|
if b[1] > int(self.settings.get("notification_rows", 20) / 2):
|
||||||
bullets_to_remove.add(b)
|
bullets_to_remove.add(b)
|
||||||
|
|
||||||
self.your_bullets = [b for b in new_yours if b not in bullets_to_remove]
|
self.your_bullets = [b for b in new_yours if b not in bullets_to_remove]
|
||||||
@@ -112,8 +113,8 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
for y in range(int(ROWS / 2)):
|
for y in range(int(self.settings.get("notification_rows", 20) / 2)):
|
||||||
for x in range(COLS):
|
for x in range(self.settings.get("notification_cols", 25)):
|
||||||
if [x, y] in self.enemies:
|
if [x, y] in self.enemies:
|
||||||
text += "~"
|
text += "~"
|
||||||
elif (x, y) in self.enemy_bullets or (x, y) in self.your_bullets:
|
elif (x, y) in self.enemy_bullets or (x, y) in self.your_bullets:
|
||||||
@@ -147,7 +148,7 @@ class Game(arcade.gui.UIView):
|
|||||||
elif symbol == arcade.key.R:
|
elif symbol == arcade.key.R:
|
||||||
self.score = 0
|
self.score = 0
|
||||||
|
|
||||||
self.ship_position = arcade.math.Vec2(0, int(ROWS / 2) - 1)
|
self.ship_position = arcade.math.Vec2(0, int(self.settings.get("notification_rows", 20) / 2) - 1)
|
||||||
self.ship_direction = arcade.math.Vec2(0, 0)
|
self.ship_direction = arcade.math.Vec2(0, 0)
|
||||||
|
|
||||||
self.enemies = []
|
self.enemies = []
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ class Game(arcade.gui.UIView):
|
|||||||
self.running = True
|
self.running = True
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
if not os.path.exists("data.json"):
|
if not os.path.exists("data.json"):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
else:
|
else:
|
||||||
@@ -111,7 +114,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.shape_tuple = self.create_shape(int(10 / 2), 0, self.shape_to_place)
|
self.shape_tuple = self.create_shape(int(10 / 2), 0, self.shape_to_place)
|
||||||
|
|
||||||
def on_update(self, delta_time):
|
def on_update(self, delta_time):
|
||||||
if self.running and time.perf_counter() - self.last_update_time >= 0.4:
|
if self.running and time.perf_counter() - self.last_update_time >= self.settings.get("notification_timeout", 0.4):
|
||||||
self.last_update_time = time.perf_counter()
|
self.last_update_time = time.perf_counter()
|
||||||
|
|
||||||
self.move_shape(*self.shape_tuple, 0, 1)
|
self.move_shape(*self.shape_tuple, 0, 1)
|
||||||
@@ -175,6 +178,8 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
self.spawn_shape()
|
self.spawn_shape()
|
||||||
|
|
||||||
|
self.info_label.text = "Use arrow keys or WASD to move the blocks\nThe game is shown inside notifications."
|
||||||
|
|
||||||
self.running = True
|
self.running = True
|
||||||
elif symbol == arcade.key.SPACE:
|
elif symbol == arcade.key.SPACE:
|
||||||
self.shape_tuple = self.rotate_shape(*self.shape_tuple)
|
self.shape_tuple = self.rotate_shape(*self.shape_tuple)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import arcade, arcade.gui, time, random, os, json
|
|||||||
|
|
||||||
from plyer import notification
|
from plyer import notification
|
||||||
|
|
||||||
from utils.constants import ROWS, COLS
|
|
||||||
from utils.preload import words
|
from utils.preload import words
|
||||||
|
|
||||||
class Game(arcade.gui.UIView):
|
class Game(arcade.gui.UIView):
|
||||||
@@ -17,6 +16,9 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
|
with open("settings.json", "r") as file:
|
||||||
|
self.settings = json.load(file)
|
||||||
|
|
||||||
if not os.path.exists("data.json"):
|
if not os.path.exists("data.json"):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -52,28 +52,31 @@ class Main(arcade.gui.UIView):
|
|||||||
|
|
||||||
self.title_label = self.box.add(arcade.gui.UILabel(text="NotifPlayground", font_name="Roboto", font_size=48))
|
self.title_label = self.box.add(arcade.gui.UILabel(text="NotifPlayground", font_name="Roboto", font_size=48))
|
||||||
|
|
||||||
self.snake_button = self.box.add(arcade.gui.UITextureButton(text="Snake", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.snake_button = self.box.add(arcade.gui.UITextureButton(text="Snake", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.snake_button.on_click = lambda event: self.snake()
|
self.snake_button.on_click = lambda event: self.snake()
|
||||||
|
|
||||||
self.flappy_bird_button = self.box.add(arcade.gui.UITextureButton(text="Flappy Bird", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.flappy_bird_button = self.box.add(arcade.gui.UITextureButton(text="Flappy Bird", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.flappy_bird_button.on_click = lambda event: self.flappy_bird()
|
self.flappy_bird_button.on_click = lambda event: self.flappy_bird()
|
||||||
|
|
||||||
self.pong_button = self.box.add(arcade.gui.UITextureButton(text="Pong", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.pong_button = self.box.add(arcade.gui.UITextureButton(text="Pong", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.pong_button.on_click = lambda event: self.pong()
|
self.pong_button.on_click = lambda event: self.pong()
|
||||||
|
|
||||||
self.space_invaders_button = self.box.add(arcade.gui.UITextureButton(text="Space Invaders", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.space_invaders_button = self.box.add(arcade.gui.UITextureButton(text="Space Invaders", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.space_invaders_button.on_click = lambda event: self.space_invaders()
|
self.space_invaders_button.on_click = lambda event: self.space_invaders()
|
||||||
|
|
||||||
self.wps_test_button = self.box.add(arcade.gui.UITextureButton(text="WPS Test", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.wps_test_button = self.box.add(arcade.gui.UITextureButton(text="WPS Test", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.wps_test_button.on_click = lambda event: self.wps_test()
|
self.wps_test_button.on_click = lambda event: self.wps_test()
|
||||||
|
|
||||||
self.maze_button = self.box.add(arcade.gui.UITextureButton(text="Maze", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.maze_button = self.box.add(arcade.gui.UITextureButton(text="Maze", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.maze_button.on_click = lambda event: self.maze()
|
self.maze_button.on_click = lambda event: self.maze()
|
||||||
|
|
||||||
self.tetris_button = self.box.add(arcade.gui.UITextureButton(text="Tetris", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.tetris_button = self.box.add(arcade.gui.UITextureButton(text="Tetris", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.tetris_button.on_click = lambda event: self.tetris()
|
self.tetris_button.on_click = lambda event: self.tetris()
|
||||||
|
|
||||||
self.settings_button = self.box.add(arcade.gui.UITextureButton(text="Settings", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 12, style=big_button_style))
|
self.hot_air_baloon_button = self.box.add(arcade.gui.UITextureButton(text="Hot Air Baloon", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
|
self.hot_air_baloon_button.on_click = lambda event: self.hot_air_baloon()
|
||||||
|
|
||||||
|
self.settings_button = self.box.add(arcade.gui.UITextureButton(text="Settings", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=self.window.height / 14, style=big_button_style))
|
||||||
self.settings_button.on_click = lambda event: self.settings()
|
self.settings_button.on_click = lambda event: self.settings()
|
||||||
|
|
||||||
def pong(self):
|
def pong(self):
|
||||||
@@ -104,6 +107,10 @@ class Main(arcade.gui.UIView):
|
|||||||
from game.tetris import Game
|
from game.tetris import Game
|
||||||
self.window.show_view(Game(self.pypresence_client))
|
self.window.show_view(Game(self.pypresence_client))
|
||||||
|
|
||||||
|
def hot_air_baloon(self):
|
||||||
|
from game.hot_air_baloon import Game
|
||||||
|
self.window.show_view(Game(self.pypresence_client))
|
||||||
|
|
||||||
def settings(self):
|
def settings(self):
|
||||||
from menus.settings import Settings
|
from menus.settings import Settings
|
||||||
self.window.show_view(Settings(self.pypresence_client))
|
self.window.show_view(Settings(self.pypresence_client))
|
||||||
|
|||||||
@@ -120,14 +120,15 @@ class Settings(arcade.gui.UIView):
|
|||||||
else:
|
else:
|
||||||
label_text = f"FPS Limit: {self.settings_dict.get(setting_dict['config_key'], setting_dict['default'])}"
|
label_text = f"FPS Limit: {self.settings_dict.get(setting_dict['config_key'], setting_dict['default'])}"
|
||||||
else:
|
else:
|
||||||
label_text = f"{setting}: {int(self.settings_dict.get(setting_dict['config_key'], setting_dict['default']))}"
|
label_text = f"{setting}: {int(self.settings_dict.get(setting_dict['config_key'], setting_dict['default'])) if setting_dict.get('step', 1) >= 1 else self.settings_dict.get(setting_dict['config_key'], setting_dict['default'])}"
|
||||||
|
|
||||||
label.text = label_text
|
label.text = label_text
|
||||||
|
|
||||||
self.slider_labels[setting] = label
|
self.slider_labels[setting] = label
|
||||||
|
|
||||||
slider = arcade.gui.UISlider(width=400, height=50, value=self.settings_dict.get(setting_dict["config_key"], setting_dict["default"]), min_value=setting_dict['min'], max_value=setting_dict['max'], style=slider_style)
|
slider = arcade.gui.UISlider(width=400, height=50, step=setting_dict.get("step", 1), value=self.settings_dict.get(setting_dict["config_key"], setting_dict["default"]), min_value=setting_dict['min'], max_value=setting_dict['max'], style=slider_style)
|
||||||
slider.on_change = lambda _, setting=setting, slider=slider: self.update(setting, slider.value, "slider")
|
slider.on_change = lambda _, setting=setting, slider=slider: self.update(setting, slider.value, "slider")
|
||||||
|
slider._render_steps = lambda surface: None
|
||||||
|
|
||||||
self.sliders[setting] = slider
|
self.sliders[setting] = slider
|
||||||
self.value_layout.add(slider)
|
self.value_layout.add(slider)
|
||||||
@@ -205,7 +206,6 @@ class Settings(arcade.gui.UIView):
|
|||||||
file.write(json.dumps(self.settings_dict, indent=4))
|
file.write(json.dumps(self.settings_dict, indent=4))
|
||||||
|
|
||||||
def update(self, setting=None, button_state=None, setting_type="bool"):
|
def update(self, setting=None, button_state=None, setting_type="bool"):
|
||||||
setting_dict = settings[self.current_category][setting]
|
|
||||||
config_key = settings[self.current_category][setting]["config_key"]
|
config_key = settings[self.current_category][setting]["config_key"]
|
||||||
|
|
||||||
if setting_type == "option":
|
if setting_type == "option":
|
||||||
@@ -222,7 +222,7 @@ class Settings(arcade.gui.UIView):
|
|||||||
self.set_normal_style(self.on_radiobuttons[setting])
|
self.set_normal_style(self.on_radiobuttons[setting])
|
||||||
|
|
||||||
elif setting_type == "slider":
|
elif setting_type == "slider":
|
||||||
new_value = int(button_state)
|
new_value = int(button_state) if settings[self.current_category][setting].get("step", 1) >= 1 else button_state
|
||||||
|
|
||||||
self.modified_settings[config_key] = new_value
|
self.modified_settings[config_key] = new_value
|
||||||
self.sliders[setting].value = new_value
|
self.sliders[setting].value = new_value
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ menu_background_color = (30, 30, 47)
|
|||||||
log_dir = 'logs'
|
log_dir = 'logs'
|
||||||
discord_presence_id = 1417184787936055336
|
discord_presence_id = 1417184787936055336
|
||||||
|
|
||||||
ROWS = 20
|
|
||||||
COLS = 25
|
|
||||||
|
|
||||||
TETRIS_SHAPES = {
|
TETRIS_SHAPES = {
|
||||||
"I": [(0, 0), (1, 0), (2, 0), (3, 0)],
|
"I": [(0, 0), (1, 0), (2, 0), (3, 0)],
|
||||||
"I_R1": [(0, 0), (0, 1), (0, 2), (0, 3)],
|
"I_R1": [(0, 0), (0, 1), (0, 2), (0, 3)],
|
||||||
@@ -37,6 +34,11 @@ slider_hover_style = UISliderStyle(bg=Color(49, 154, 54), unfilled_track=Color(1
|
|||||||
slider_style = {'normal': slider_default_style, 'hover': slider_hover_style, 'press': slider_hover_style, 'disabled': slider_default_style}
|
slider_style = {'normal': slider_default_style, 'hover': slider_hover_style, 'press': slider_hover_style, 'disabled': slider_default_style}
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
|
"Games": {
|
||||||
|
"Notification Timeout": {"type": "slider", "min": 0.1, "max": 3, "step": 0.1, "config_key": "notification_timeout", "default": 0.4},
|
||||||
|
"Notification Rows (Changing can break games!)": {"type": "slider", "min": 8, "max": 100, "config_key": "notification_rows", "default": 20},
|
||||||
|
"Notification Columns (Changing can break games!)": {"type": "slider", "min": 8, "max": 100, "config_key": "notification_cols", "default": 25}
|
||||||
|
},
|
||||||
"Graphics": {
|
"Graphics": {
|
||||||
"Window Mode": {"type": "option", "options": ["Windowed", "Fullscreen", "Borderless"], "config_key": "window_mode", "default": "Windowed"},
|
"Window Mode": {"type": "option", "options": ["Windowed", "Fullscreen", "Borderless"], "config_key": "window_mode", "default": "Windowed"},
|
||||||
"Resolution": {"type": "option", "options": ["1366x768", "1440x900", "1600x900", "1920x1080", "2560x1440", "3840x2160"], "config_key": "resolution"},
|
"Resolution": {"type": "option", "options": ["1366x768", "1440x900", "1600x900", "1920x1080", "2560x1440", "3840x2160"], "config_key": "resolution"},
|
||||||
@@ -55,4 +57,4 @@ settings = {
|
|||||||
},
|
},
|
||||||
"Credits": {}
|
"Credits": {}
|
||||||
}
|
}
|
||||||
settings_start_category = "Graphics"
|
settings_start_category = "Games"
|
||||||
|
|||||||
Reference in New Issue
Block a user