From 152e509decd7189430020a2a0b140a861f01568a Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 12 Mar 2026 13:15:35 -0400 Subject: [PATCH] added some debugging tools --- tools.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools.py b/tools.py index e69de29..9eb81cc 100644 --- a/tools.py +++ b/tools.py @@ -0,0 +1,51 @@ +import pygame as pg +from queue import Queue + + +def _debug(fn): + def wrapper(self: 'Debug', *args, **kwargs): + if not self.enabled: return + fn(self, *args, **kwargs) + return wrapper + +class Debug: + + def __init__(self, enabled=False): + self.enabled = enabled + self._screen = None + self._debug_queue = Queue() + + + def debug(self): + while not self._debug_queue.empty(): + self._debug_queue.get()() + + @_debug + def draw_lines(self, points) -> None: + def _draw_lines(): + if len(points) > 1: + pg.draw.lines( + self._screen, + (255,0,255), + False, + points=points, + width=3 + ) + for point in points: + pg.draw.circle( + self._screen, + (255,0,255), + point, + 2 + ) + if len(points) > 0: + pg.draw.circle( + self._screen, + (255,0,255), + points[0], + 2 + ) + self._debug_queue.put(_draw_lines) + + +debug = Debug()