mini-arcade-core 0.7.0__py3-none-any.whl → 0.7.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.
- mini_arcade_core/backend.py +8 -0
- mini_arcade_core/game.py +18 -0
- mini_arcade_core/scene.py +29 -0
- {mini_arcade_core-0.7.0.dist-info → mini_arcade_core-0.7.2.dist-info}/METADATA +1 -1
- mini_arcade_core-0.7.2.dist-info/RECORD +9 -0
- mini_arcade_core-0.7.0.dist-info/RECORD +0 -9
- {mini_arcade_core-0.7.0.dist-info → mini_arcade_core-0.7.2.dist-info}/WHEEL +0 -0
- {mini_arcade_core-0.7.0.dist-info → mini_arcade_core-0.7.2.dist-info}/licenses/LICENSE +0 -0
mini_arcade_core/backend.py
CHANGED
|
@@ -103,3 +103,11 @@ class Backend(Protocol):
|
|
|
103
103
|
Backends may ignore advanced styling for now; this is just to render
|
|
104
104
|
simple labels like menu items, scores, etc.
|
|
105
105
|
"""
|
|
106
|
+
|
|
107
|
+
def capture_frame(self, path: str | None = None) -> bytes | None:
|
|
108
|
+
"""
|
|
109
|
+
Capture the current frame.
|
|
110
|
+
If `path` is provided, save to that file (e.g. PNG).
|
|
111
|
+
Returns raw bytes (PNG) or None if unsupported.
|
|
112
|
+
"""
|
|
113
|
+
raise NotImplementedError
|
mini_arcade_core/game.py
CHANGED
|
@@ -4,7 +4,9 @@ Game core module defining the Game class and configuration.
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import os
|
|
7
8
|
from dataclasses import dataclass
|
|
9
|
+
from datetime import datetime
|
|
8
10
|
from time import perf_counter, sleep
|
|
9
11
|
from typing import TYPE_CHECKING
|
|
10
12
|
|
|
@@ -116,3 +118,19 @@ class Game:
|
|
|
116
118
|
|
|
117
119
|
if self._current_scene is not None:
|
|
118
120
|
self._current_scene.on_exit()
|
|
121
|
+
|
|
122
|
+
def screenshot(
|
|
123
|
+
self, label: str | None = None, directory: str = "screenshots"
|
|
124
|
+
) -> str | None:
|
|
125
|
+
"""
|
|
126
|
+
Ask backend to save a screenshot. Returns the file path or None.
|
|
127
|
+
"""
|
|
128
|
+
os.makedirs(directory, exist_ok=True)
|
|
129
|
+
stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
130
|
+
label = label or "shot"
|
|
131
|
+
filename = f"{stamp}_{label}.png"
|
|
132
|
+
path = os.path.join(directory, filename)
|
|
133
|
+
|
|
134
|
+
if self.backend.capture_frame(path):
|
|
135
|
+
return path
|
|
136
|
+
return None
|
mini_arcade_core/scene.py
CHANGED
|
@@ -5,9 +5,14 @@ Base class for game scenes (states/screens).
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
7
|
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import Callable, List
|
|
9
|
+
|
|
10
|
+
from mini_arcade_core.backend import Backend
|
|
8
11
|
|
|
9
12
|
from .game import Game
|
|
10
13
|
|
|
14
|
+
OverlayFunc = Callable[[Backend], None]
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
class Scene(ABC):
|
|
13
18
|
"""Base class for game scenes (states/screens)."""
|
|
@@ -18,6 +23,24 @@ class Scene(ABC):
|
|
|
18
23
|
:type game: Game
|
|
19
24
|
"""
|
|
20
25
|
self.game = game
|
|
26
|
+
# overlays drawn on top of the scene
|
|
27
|
+
self._overlays: List[OverlayFunc] = []
|
|
28
|
+
|
|
29
|
+
def add_overlay(self, overlay: OverlayFunc) -> None:
|
|
30
|
+
"""Register an overlay (drawn every frame, after entities)."""
|
|
31
|
+
self._overlays.append(overlay)
|
|
32
|
+
|
|
33
|
+
def remove_overlay(self, overlay: OverlayFunc) -> None:
|
|
34
|
+
if overlay in self._overlays:
|
|
35
|
+
self._overlays.remove(overlay)
|
|
36
|
+
|
|
37
|
+
def clear_overlays(self) -> None:
|
|
38
|
+
self._overlays.clear()
|
|
39
|
+
|
|
40
|
+
def draw_overlays(self, surface: Backend) -> None:
|
|
41
|
+
"""Call all overlays. Scenes should call this at the end of draw()."""
|
|
42
|
+
for overlay in self._overlays:
|
|
43
|
+
overlay(surface)
|
|
21
44
|
|
|
22
45
|
@abstractmethod
|
|
23
46
|
def on_enter(self):
|
|
@@ -38,3 +61,9 @@ class Scene(ABC):
|
|
|
38
61
|
@abstractmethod
|
|
39
62
|
def draw(self, surface: object):
|
|
40
63
|
"""Render to the main surface."""
|
|
64
|
+
|
|
65
|
+
def draw(self, surface: object):
|
|
66
|
+
"""Render to the main surface."""
|
|
67
|
+
|
|
68
|
+
def draw(self, surface: object):
|
|
69
|
+
"""Render to the main surface."""
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mini_arcade_core/__init__.py,sha256=0PFa04KRSY3kT8YoD24zfFt92HYfrk6QrH8IlHbmeo4,1753
|
|
2
|
+
mini_arcade_core/backend.py,sha256=DZUEO4zMlXIk3ctD9ZNqvgOo7n_ZKpC6x--hIede_YY,2946
|
|
3
|
+
mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
|
|
4
|
+
mini_arcade_core/game.py,sha256=yRMy0IJVB_yuF9P_SKjcxJG0YVMs52khVFLomSUeVw8,3935
|
|
5
|
+
mini_arcade_core/scene.py,sha256=i8lmcTZ1IPcM-NDwVvKrvjCMcFVq1aD5nacOvU0ZONU,1883
|
|
6
|
+
mini_arcade_core-0.7.2.dist-info/METADATA,sha256=UNpZCJ0APedKmetmYqtENHGlSIgW2uDjsvr2eYxlidI,8296
|
|
7
|
+
mini_arcade_core-0.7.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
8
|
+
mini_arcade_core-0.7.2.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
|
|
9
|
+
mini_arcade_core-0.7.2.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
mini_arcade_core/__init__.py,sha256=0PFa04KRSY3kT8YoD24zfFt92HYfrk6QrH8IlHbmeo4,1753
|
|
2
|
-
mini_arcade_core/backend.py,sha256=Vus-TIU16ySSGKuy1S-sBWkpb2WUZCbUHYBPcwGpW9o,2665
|
|
3
|
-
mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
|
|
4
|
-
mini_arcade_core/game.py,sha256=G9x5FCzJN0KsnCy063sBgWkr3WkbPOJ8_SOHaslZ1mQ,3369
|
|
5
|
-
mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
|
|
6
|
-
mini_arcade_core-0.7.0.dist-info/METADATA,sha256=wRO23CTApLzioWwh50uJQPU823HRURJCRLueAabity0,8296
|
|
7
|
-
mini_arcade_core-0.7.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
8
|
-
mini_arcade_core-0.7.0.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
|
|
9
|
-
mini_arcade_core-0.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|