mini-arcade-core 0.6.1__py3-none-any.whl → 0.7.1__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.
@@ -57,6 +57,11 @@ class Backend(Protocol):
57
57
  Concrete backends will translate their native events into core Event objects.
58
58
  """
59
59
 
60
+ def set_clear_color(self, r: int, g: int, b: int) -> None:
61
+ """
62
+ Set the background/clear color used by begin_frame.
63
+ """
64
+
60
65
  def begin_frame(self) -> None:
61
66
  """
62
67
  Prepare for drawing a new frame (e.g. clear screen).
@@ -67,9 +72,42 @@ class Backend(Protocol):
67
72
  Present the frame to the user (swap buffers).
68
73
  """
69
74
 
70
- def draw_rect(self, x: int, y: int, w: int, h: int) -> None:
75
+ # Justification: Simple drawing API for now
76
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
77
+ def draw_rect(
78
+ self,
79
+ x: int,
80
+ y: int,
81
+ w: int,
82
+ h: int,
83
+ color: tuple[int, int, int] = (255, 255, 255),
84
+ ) -> None:
71
85
  """
72
86
  Draw a filled rectangle in some default color.
73
87
 
74
88
  We'll keep this minimal for now; later we can extend with colors/sprites.
75
89
  """
90
+
91
+ # pylint: enable=too-many-arguments,too-many-positional-arguments
92
+
93
+ def draw_text(
94
+ self,
95
+ x: int,
96
+ y: int,
97
+ text: str,
98
+ color: tuple[int, int, int] = (255, 255, 255),
99
+ ) -> None:
100
+ """
101
+ Draw text at the given position in a default font and color.
102
+
103
+ Backends may ignore advanced styling for now; this is just to render
104
+ simple labels like menu items, scores, etc.
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
 
@@ -32,7 +34,7 @@ class GameConfig:
32
34
  title: str = "Mini Arcade Game"
33
35
  fps: int = 60
34
36
  background_color: tuple[int, int, int] = (0, 0, 0)
35
- backend: type[Backend] | None = None
37
+ backend: Backend | None = None
36
38
 
37
39
 
38
40
  class Game:
@@ -84,6 +86,9 @@ class Game:
84
86
  backend = self.backend
85
87
  backend.init(self.config.width, self.config.height, self.config.title)
86
88
 
89
+ br, bg, bb = self.config.background_color
90
+ backend.set_clear_color(br, bg, bb)
91
+
87
92
  self.change_scene(initial_scene)
88
93
 
89
94
  self._running = True
@@ -113,3 +118,19 @@ class Game:
113
118
 
114
119
  if self._current_scene is not None:
115
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.6.1
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
 
@@ -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=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
6
+ mini_arcade_core-0.7.1.dist-info/METADATA,sha256=KNIe3xKd_vY9eKTYdg6CujZL93-uznlqVXQaU3jl9M4,8296
7
+ mini_arcade_core-0.7.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ mini_arcade_core-0.7.1.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
+ mini_arcade_core-0.7.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- mini_arcade_core/__init__.py,sha256=0PFa04KRSY3kT8YoD24zfFt92HYfrk6QrH8IlHbmeo4,1753
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=5mLbi3IzgfRXBTwl88L-ooez16NtwLKLQZzYvMkLHco,3280
5
- mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
6
- mini_arcade_core-0.6.1.dist-info/METADATA,sha256=pXNVRAEdlB52_Vz50sUTIPLoYLjMrPyvLfYFQsDXspw,8296
7
- mini_arcade_core-0.6.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
- mini_arcade_core-0.6.1.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
- mini_arcade_core-0.6.1.dist-info/RECORD,,