mini-arcade-core 0.6.1__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.
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/PKG-INFO +1 -1
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/pyproject.toml +1 -1
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/src/mini_arcade_core/backend.py +39 -1
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/src/mini_arcade_core/game.py +22 -1
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/LICENSE +0 -0
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/README.md +0 -0
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/src/mini_arcade_core/__init__.py +0 -0
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/src/mini_arcade_core/entity.py +0 -0
- {mini_arcade_core-0.6.1 → mini_arcade_core-0.7.1}/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.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" },
|
|
@@ -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
|
-
|
|
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
|
|
@@ -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:
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|