PygameToolsOcto 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: PygameToolsOcto
3
+ Version: 1.0.0
4
+ Summary: Bibliothèque qui dispose de divers classes, fonctions et décorateurs pour aider au développement avec pygame
5
+ Requires-Dist: DecoratorToolkit>=1.0.0
6
+ Requires-Dist: pygame-ce>=2.5.0
@@ -0,0 +1,21 @@
1
+ import pygame
2
+
3
+ def Timer(seconds: int=1):
4
+
5
+ now = pygame.time.get_ticks()
6
+
7
+ def decorator(function):
8
+
9
+ now = pygame.time.get_ticks()
10
+
11
+ def execute(*args, **kwargs):
12
+ nonlocal now
13
+
14
+ current = pygame.time.get_ticks()
15
+
16
+ if current - now >= seconds * 1000:
17
+ now = current
18
+ return function(*args, **kwargs)
19
+ return execute
20
+ return decorator
21
+
@@ -0,0 +1,19 @@
1
+ from functools import wraps
2
+ import pygame
3
+
4
+ from .eventManager import EventManager
5
+
6
+ def EventListener(event: int | list[int], condition: bool=True):
7
+
8
+ def decorator(func):
9
+
10
+ @wraps(func)
11
+ def wrapper(self, *args, **kwargs):
12
+ if condition:
13
+ return func(self, *args, **kwargs)
14
+
15
+ wrapper.__event_type__ = event
16
+
17
+ return wrapper
18
+
19
+ return decorator
@@ -0,0 +1,42 @@
1
+ import pygame
2
+
3
+ from Decorators.classes.singleton import Singleton #type: ignore
4
+
5
+ @Singleton()
6
+ class EventManager:
7
+
8
+ listeners = {}
9
+
10
+ def __init__(self):
11
+ pass
12
+
13
+ def register(self, instance):
14
+
15
+ for name in dir(instance):
16
+ method = getattr(instance, name)
17
+
18
+ if not hasattr(method, "__event_type__"):
19
+ continue
20
+
21
+ event_types = method.__event_type__
22
+ if not isinstance(event_types, (list, tuple, set)):
23
+ event_types = [event_types]
24
+
25
+ for event in event_types:
26
+ self.listeners.setdefault(event, []).append(method)
27
+
28
+ def clear(self):
29
+
30
+ self.listeners.clear()
31
+
32
+
33
+ @classmethod
34
+ def listen(cls, onQuit: callable):
35
+
36
+ for event in pygame.event.get():
37
+
38
+ if event.type == pygame.QUIT:
39
+ onQuit()
40
+
41
+ for listener in cls.listeners.get(event.type, []):
42
+ listener(event)
@@ -0,0 +1,9 @@
1
+ import pygame
2
+
3
+ from .eventManager import EventManager
4
+
5
+ class EventObject:
6
+
7
+ def __init__(self):
8
+
9
+ EventManager().register(self)
@@ -0,0 +1,27 @@
1
+ from .eventObject import EventObject
2
+ from functools import wraps
3
+
4
+ def IsEventObject():
5
+
6
+ def decorator(cls):
7
+
8
+ original_init = cls.__init__
9
+
10
+ @wraps(original_init)
11
+ def __init__(self, *args, **kwargs):
12
+
13
+ original_init(self, *args, **kwargs)
14
+
15
+ EventObject.__init__(self)
16
+
17
+
18
+ newType = type(
19
+ cls.__name__,
20
+ (cls, EventObject),
21
+ {
22
+ "__init__" : __init__
23
+ }
24
+ )
25
+
26
+ return newType
27
+ return decorator
@@ -0,0 +1,25 @@
1
+ from enum import Enum
2
+
3
+ class Color(Enum):
4
+
5
+ RED = (255, 0, 0)
6
+ GREEN = (0, 255, 0)
7
+ BLUE = (0, 0, 255)
8
+
9
+ PURPLE = (255, 0, 255)
10
+ YELLOW = (255, 255, 0)
11
+
12
+ BLACK = (0, 0, 0)
13
+ WHITE = (255, 255, 255)
14
+
15
+ @property
16
+ def r(self):
17
+ return self.value[0]
18
+
19
+ @property
20
+ def g(self):
21
+ return self.value[1]
22
+
23
+ @property
24
+ def b(self):
25
+ return self.value[2]
@@ -0,0 +1,10 @@
1
+ from .Event.eventListener import EventListener
2
+ from .Event.eventManager import EventManager
3
+ from .Decorators.timer import Timer
4
+
5
+
6
+ __all__ = [
7
+ EventManager,
8
+ EventListener,
9
+ Timer
10
+ ]
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: PygameToolsOcto
3
+ Version: 1.0.0
4
+ Summary: Bibliothèque qui dispose de divers classes, fonctions et décorateurs pour aider au développement avec pygame
5
+ Requires-Dist: DecoratorToolkit>=1.0.0
6
+ Requires-Dist: pygame-ce>=2.5.0
@@ -0,0 +1,13 @@
1
+ pyproject.toml
2
+ PygameTools/__init__.py
3
+ PygameToolsOcto.egg-info/PKG-INFO
4
+ PygameToolsOcto.egg-info/SOURCES.txt
5
+ PygameToolsOcto.egg-info/dependency_links.txt
6
+ PygameToolsOcto.egg-info/requires.txt
7
+ PygameToolsOcto.egg-info/top_level.txt
8
+ PygameTools/Decorators/timer.py
9
+ PygameTools/Event/eventListener.py
10
+ PygameTools/Event/eventManager.py
11
+ PygameTools/Event/eventObject.py
12
+ PygameTools/Event/isEventObject.py
13
+ PygameTools/Graphics/color.py
@@ -0,0 +1,2 @@
1
+ DecoratorToolkit>=1.0.0
2
+ pygame-ce>=2.5.0
@@ -0,0 +1,3 @@
1
+ PygameTools
2
+ build
3
+ dist
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "PygameToolsOcto"
7
+ version = "1.0.0"
8
+ description = "Bibliothèque qui dispose de divers classes, fonctions et décorateurs pour aider au développement avec pygame"
9
+
10
+ dependencies = [
11
+ "DecoratorToolkit>=1.0.0",
12
+ "pygame-ce>=2.5.0"
13
+ ]
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+