mini-arcade-core 0.3.2__py3-none-any.whl → 0.5.2__py3-none-any.whl

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.
@@ -5,11 +5,16 @@ Provides access to core classes and a convenience function to run a game.
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ import logging
9
+ from importlib.metadata import PackageNotFoundError, version
10
+
8
11
  from .backend import Backend, Event, EventType
9
12
  from .entity import Entity, SpriteEntity
10
13
  from .game import Game, GameConfig
11
14
  from .scene import Scene
12
15
 
16
+ logger = logging.getLogger(__name__)
17
+
13
18
 
14
19
  def run_game(initial_scene_cls: type[Scene], config: GameConfig | None = None):
15
20
  """
@@ -34,3 +39,38 @@ __all__ = [
34
39
  "Event",
35
40
  "EventType",
36
41
  ]
42
+
43
+ PACKAGE_NAME = "mini-arcade-core" # or whatever is in your pyproject.toml
44
+
45
+
46
+ def get_version() -> str:
47
+ """
48
+ Return the installed package version.
49
+
50
+ This is a thin helper around importlib.metadata.version so games can do:
51
+
52
+ from mini_arcade_core import get_version
53
+ print(get_version())
54
+
55
+ :return: The version string of the installed package.
56
+ :rtype: str
57
+
58
+ :raises PackageNotFoundError: If the package is not installed.
59
+ """
60
+ try:
61
+ return version(PACKAGE_NAME)
62
+ except PackageNotFoundError: # if running from source / editable
63
+ logger.warning(
64
+ f"Package '{PACKAGE_NAME}' not found. Returning default version '0.0.0'."
65
+ )
66
+ return "0.0.0"
67
+
68
+
69
+ try:
70
+ __version__ = get_version()
71
+ # Justification: We want to ensure that any exception during version retrieval
72
+ # results in a default version being set, rather than crashing the import.
73
+ # pylint: disable=broad-exception-caught
74
+ except Exception:
75
+ __version__ = "0.0.0"
76
+ # pylint: enable=broad-exception-caught
mini_arcade_core/game.py CHANGED
@@ -7,6 +7,8 @@ from __future__ import annotations
7
7
  from dataclasses import dataclass
8
8
  from typing import TYPE_CHECKING
9
9
 
10
+ from .backend import Backend
11
+
10
12
  if TYPE_CHECKING: # avoid runtime circular import
11
13
  from .scene import Scene
12
14
 
@@ -21,6 +23,7 @@ class GameConfig:
21
23
  :ivar title: Title of the game window.
22
24
  :ivar fps: Target frames per second.
23
25
  :ivar background_color: RGB background color.
26
+ :ivar backend: Optional backend class to use for rendering and input.
24
27
  """
25
28
 
26
29
  width: int = 800
@@ -28,6 +31,7 @@ class GameConfig:
28
31
  title: str = "Mini Arcade Game"
29
32
  fps: int = 60
30
33
  background_color: tuple[int, int, int] = (0, 0, 0)
34
+ backend: type[Backend] | None = None
31
35
 
32
36
 
33
37
  class Game:
@@ -40,6 +44,7 @@ class Game:
40
44
  self.config = config
41
45
  self._current_scene: Scene | None = None
42
46
  self._running: bool = False
47
+ self.backend: Backend | None = config.backend
43
48
 
44
49
  def change_scene(self, scene: Scene):
45
50
  """
@@ -52,6 +57,10 @@ class Game:
52
57
  "Game.change_scene must be implemented by a concrete backend."
53
58
  )
54
59
 
60
+ def quit(self):
61
+ """Request that the main loop stops."""
62
+ self._running = False
63
+
55
64
  def run(self, initial_scene: Scene):
56
65
  """
57
66
  Run the main loop starting with the given scene.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.3.2
3
+ Version: 0.5.2
4
4
  Summary: Tiny scene-based game loop core for small arcade games.
5
5
  License: Copyright (c) 2025 Santiago Rincón
6
6
 
@@ -0,0 +1,9 @@
1
+ mini_arcade_core/__init__.py,sha256=xlePCq6tvPfIgHlhQ-WtESvEyX2sjkgu_aann-1QsZk,2041
2
+ mini_arcade_core/backend.py,sha256=6_3-ni0EQJXfaSReavcrOeUOCNkdrjGctFn5q0D9nrw,1847
3
+ mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
4
+ mini_arcade_core/game.py,sha256=OkQIFkFLqFailZDPY1fAq6Tyi7IQ9EKxloW1UgDaHko,2123
5
+ mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
6
+ mini_arcade_core-0.5.2.dist-info/METADATA,sha256=5ogfRfSrJtRHRqnSAGo2ZSNQWDMal3USAFZ3rCeJGtY,8296
7
+ mini_arcade_core-0.5.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ mini_arcade_core-0.5.2.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
+ mini_arcade_core-0.5.2.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- mini_arcade_core/__init__.py,sha256=c66IkzZjiyUbTtjQRyf4XyiH6xPS79Ajxeb1OvnVPZA,887
2
- mini_arcade_core/backend.py,sha256=6_3-ni0EQJXfaSReavcrOeUOCNkdrjGctFn5q0D9nrw,1847
3
- mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
4
- mini_arcade_core/game.py,sha256=j9savb7y3NPgQsiX3xeRTrEadP7xzIpfsekE74s8AAY,1825
5
- mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
6
- mini_arcade_core-0.3.2.dist-info/METADATA,sha256=Zl_Dq8BvNSj8kenLvLDiixNZkTt1gwTBXvQIZuh3adc,8296
7
- mini_arcade_core-0.3.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
- mini_arcade_core-0.3.2.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
- mini_arcade_core-0.3.2.dist-info/RECORD,,