mini-arcade-core 0.3.2__tar.gz → 0.5.2__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.
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/PKG-INFO +1 -1
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/pyproject.toml +3 -1
- mini_arcade_core-0.5.2/src/mini_arcade_core/__init__.py +76 -0
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/src/mini_arcade_core/game.py +9 -0
- mini_arcade_core-0.3.2/src/mini_arcade_core/__init__.py +0 -36
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/LICENSE +0 -0
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/README.md +0 -0
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/src/mini_arcade_core/backend.py +0 -0
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/src/mini_arcade_core/entity.py +0 -0
- {mini_arcade_core-0.3.2 → mini_arcade_core-0.5.2}/src/mini_arcade_core/scene.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mini-arcade-core"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.2"
|
|
8
8
|
description = "Tiny scene-based game loop core for small arcade games."
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Santiago Rincon", email = "rincores@gmail.com" },
|
|
@@ -57,6 +57,8 @@ strict = false
|
|
|
57
57
|
disable = [
|
|
58
58
|
# Justification: Allow classes with few public methods for simplicity.
|
|
59
59
|
"too-few-public-methods",
|
|
60
|
+
# Justification: f-strings are preferred for logging.
|
|
61
|
+
"logging-fstring-interpolation",
|
|
60
62
|
# Justification: TODOs are acceptable during development.
|
|
61
63
|
"fixme",
|
|
62
64
|
]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for the mini_arcade_core package.
|
|
3
|
+
Provides access to core classes and a convenience function to run a game.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
10
|
+
|
|
11
|
+
from .backend import Backend, Event, EventType
|
|
12
|
+
from .entity import Entity, SpriteEntity
|
|
13
|
+
from .game import Game, GameConfig
|
|
14
|
+
from .scene import Scene
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def run_game(initial_scene_cls: type[Scene], config: GameConfig | None = None):
|
|
20
|
+
"""
|
|
21
|
+
Convenience helper to bootstrap and run a game with a single scene.
|
|
22
|
+
|
|
23
|
+
:param initial_scene_cls: The Scene subclass to instantiate as the initial scene.
|
|
24
|
+
:param config: Optional GameConfig to customize game settings.
|
|
25
|
+
"""
|
|
26
|
+
game = Game(config or GameConfig())
|
|
27
|
+
scene = initial_scene_cls(game)
|
|
28
|
+
game.run(scene)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"Game",
|
|
33
|
+
"GameConfig",
|
|
34
|
+
"Scene",
|
|
35
|
+
"Entity",
|
|
36
|
+
"SpriteEntity",
|
|
37
|
+
"run_game",
|
|
38
|
+
"Backend",
|
|
39
|
+
"Event",
|
|
40
|
+
"EventType",
|
|
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
|
|
@@ -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,36 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Entry point for the mini_arcade_core package.
|
|
3
|
-
Provides access to core classes and a convenience function to run a game.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from __future__ import annotations
|
|
7
|
-
|
|
8
|
-
from .backend import Backend, Event, EventType
|
|
9
|
-
from .entity import Entity, SpriteEntity
|
|
10
|
-
from .game import Game, GameConfig
|
|
11
|
-
from .scene import Scene
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def run_game(initial_scene_cls: type[Scene], config: GameConfig | None = None):
|
|
15
|
-
"""
|
|
16
|
-
Convenience helper to bootstrap and run a game with a single scene.
|
|
17
|
-
|
|
18
|
-
:param initial_scene_cls: The Scene subclass to instantiate as the initial scene.
|
|
19
|
-
:param config: Optional GameConfig to customize game settings.
|
|
20
|
-
"""
|
|
21
|
-
game = Game(config or GameConfig())
|
|
22
|
-
scene = initial_scene_cls(game)
|
|
23
|
-
game.run(scene)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__all__ = [
|
|
27
|
-
"Game",
|
|
28
|
-
"GameConfig",
|
|
29
|
-
"Scene",
|
|
30
|
-
"Entity",
|
|
31
|
-
"SpriteEntity",
|
|
32
|
-
"run_game",
|
|
33
|
-
"Backend",
|
|
34
|
-
"Event",
|
|
35
|
-
"EventType",
|
|
36
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|