mini-arcade-core 0.7.0__tar.gz → 0.7.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Tiny scene-based game loop core for small arcade games.
5
5
  License: Copyright (c) 2025 Santiago Rincón
6
6
 
@@ -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.0"
7
+ version = "0.7.1"
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" },
@@ -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
@@ -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