mini-arcade-core 0.9.6__py3-none-any.whl → 0.9.7__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.
@@ -1,41 +1,13 @@
1
1
  """
2
2
  Entry point for the mini_arcade_core package.
3
3
  Provides access to core classes and a convenience function to run a game.
4
-
5
- mini_arcade_core/
6
- |-- __init__.py # main entry point
7
- |-- game.py # core game loop and management
8
- |-- entity.py # base entity classes
9
- |-- backend/ # backend abstraction layer
10
- | |-- __init__.py
11
- | |-- backend.py # abstract Backend class
12
- | |-- events.py # event definitions
13
- | |-- types.py # common types like Color
14
- |-- keymaps/ # key mapping utilities
15
- | |-- __init__.py
16
- | |-- keys.py # key definitions and keymaps
17
- | |-- sdl.py # SDL keycode mappings
18
- |-- scenes/ # scene management
19
- | |-- __init__.py
20
- | |-- autoreg.py # automatic scene registration
21
- | |-- registry.py # SceneRegistry class
22
- | |-- scene.py # base Scene class
23
- |-- two_d/ # 2D utilities and types
24
- | |-- __init__.py
25
- | |-- boundaries2d.py # boundary behaviors
26
- | |-- collision2d.py # collision detection
27
- | |-- geometry2d.py # geometric types like Position2D, Size2D
28
- | |-- kinematics2d.py # kinematic data structures
29
- | |-- physics2d.py # physics-related types like Velocity2D
30
- |-- ui/ # user interface components
31
- | |-- __init__.py
32
- | |-- menu.py # menu components
33
4
  """
34
5
 
35
6
  from __future__ import annotations
36
7
 
37
8
  import logging
38
9
  from importlib.metadata import PackageNotFoundError, version
10
+ from typing import Callable, Type, Union
39
11
 
40
12
  from mini_arcade_core.backend import Backend, Event, EventType
41
13
  from mini_arcade_core.entity import Entity, KinematicEntity, SpriteEntity
@@ -55,19 +27,27 @@ from mini_arcade_core.two_d import (
55
27
  VerticalWrap,
56
28
  )
57
29
 
30
+ SceneFactoryLike = Union[Type[Scene], Callable[[Game], Scene]]
31
+
58
32
  logger = logging.getLogger(__name__)
59
33
 
60
34
 
61
35
  def run_game(
62
- initial_scene_cls: type[Scene],
36
+ scene: SceneFactoryLike | None = None,
63
37
  config: GameConfig | None = None,
64
38
  registry: SceneRegistry | None = None,
39
+ initial_scene: str = "main",
65
40
  ):
66
41
  """
67
42
  Convenience helper to bootstrap and run a game with a single scene.
68
43
 
69
- :param initial_scene_cls: The Scene subclass to instantiate as the initial scene.
70
- :type initial_scene_cls: type[Scene]
44
+ Supports both:
45
+ - run_game(SceneClass, cfg) # legacy
46
+ - run_game(config=cfg, initial_scene="main", registry=...) # registry-based
47
+ - run_game(cfg) # config-only
48
+
49
+ :param initial_scene: The Scene ID to start the game with.
50
+ :type initial_scene: str
71
51
 
72
52
  :param config: Optional GameConfig to customize game settings.
73
53
  :type config: GameConfig | None
@@ -77,14 +57,27 @@ def run_game(
77
57
 
78
58
  :raises ValueError: If the provided config does not have a valid Backend.
79
59
  """
60
+ # Handle run_game(cfg) where the first arg is actually a GameConfig
61
+ if isinstance(scene, GameConfig) and config is None:
62
+ config = scene
63
+ scene = None
64
+
80
65
  cfg = config or GameConfig()
81
- if config.backend is None:
66
+ if cfg.backend is None:
82
67
  raise ValueError(
83
68
  "GameConfig.backend must be set to a Backend instance"
84
69
  )
70
+
71
+ # If user provided a Scene factory/class, ensure it's registered
72
+ if scene is not None:
73
+ if registry is None:
74
+ registry = SceneRegistry(_factories={})
75
+ registry.register(
76
+ initial_scene, scene
77
+ ) # Scene class is callable(game) -> Scene
78
+
85
79
  game = Game(cfg, registry=registry)
86
- scene = initial_scene_cls(game)
87
- game.run(scene)
80
+ game.run(initial_scene)
88
81
 
89
82
 
90
83
  __all__ = [
@@ -141,6 +134,3 @@ def get_version() -> str:
141
134
 
142
135
 
143
136
  __version__ = get_version()
144
- __version__ = get_version()
145
- __version__ = get_version()
146
- __version__ = get_version()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: Tiny scene-based game loop core for small arcade games.
5
5
  License: Copyright (c) 2025 Santiago Rincón
6
6
 
@@ -1,4 +1,4 @@
1
- mini_arcade_core/__init__.py,sha256=yAtLsSrBZD3778nStf0XQjKn5hTP-daYkddk7_dAGe4,4029
1
+ mini_arcade_core/__init__.py,sha256=Q6N1eJe5W8r3i_G88-WZ90B71P6eFuH-Zk5xw3p7SBs,3650
2
2
  mini_arcade_core/backend/__init__.py,sha256=w-6QTUngdIYZuvEU3B8zL-vXyKbyLDVucbt7yKZdLlc,379
3
3
  mini_arcade_core/backend/backend.py,sha256=dLXTtLn5qURftWOWOVQd2ouuZmJpbiOl11KMIDRk2us,4026
4
4
  mini_arcade_core/backend/events.py,sha256=usn2HTk5-5ZiaU2IjbrNRpEj_4uoaiqfY3qufQLYy0w,2929
@@ -20,7 +20,7 @@ mini_arcade_core/two_d/kinematics2d.py,sha256=NFMiIzDYqDquyg_EhD7EQBJ_Sz4RncmkEj
20
20
  mini_arcade_core/two_d/physics2d.py,sha256=qIq86qWVuvcnLIMEPH6xx7XQO4tQhfiMZY6FseuVOR8,1636
21
21
  mini_arcade_core/ui/__init__.py,sha256=RmcZXfBFFmL09j_Bo1LHagRjiKYajuySPilIUNjc3KQ,248
22
22
  mini_arcade_core/ui/menu.py,sha256=J3hYY46xOHLN65WSet4-cnQU7L5pu48scjLJUW9IkEM,13681
23
- mini_arcade_core-0.9.6.dist-info/METADATA,sha256=TXCP-kgqZegagNZ6_Zoa_lLU0nhNiC6yVGnHpv4iRjM,8188
24
- mini_arcade_core-0.9.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
25
- mini_arcade_core-0.9.6.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
26
- mini_arcade_core-0.9.6.dist-info/RECORD,,
23
+ mini_arcade_core-0.9.7.dist-info/METADATA,sha256=ghW7JHVtzj3xDdaQHOvhHmo0JjtLM5Rqpk0K-05RqOI,8188
24
+ mini_arcade_core-0.9.7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
25
+ mini_arcade_core-0.9.7.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
26
+ mini_arcade_core-0.9.7.dist-info/RECORD,,