mini-arcade-core 0.2.3__py3-none-any.whl → 0.3.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.
@@ -5,6 +5,7 @@ Provides access to core classes and a convenience function to run a game.
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ from .backend import Backend, Event, EventType
8
9
  from .entity import Entity, SpriteEntity
9
10
  from .game import Game, GameConfig
10
11
  from .scene import Scene
@@ -29,4 +30,7 @@ __all__ = [
29
30
  "Entity",
30
31
  "SpriteEntity",
31
32
  "run_game",
33
+ "Backend",
34
+ "Event",
35
+ "EventType",
32
36
  ]
@@ -0,0 +1,75 @@
1
+ """
2
+ Backend interface for rendering and input.
3
+ This is the only part of the code that talks to SDL/pygame directly.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass
9
+ from enum import Enum, auto
10
+ from typing import Iterable, Protocol
11
+
12
+
13
+ class EventType(Enum):
14
+ """High-level event types understood by the core."""
15
+
16
+ UNKNOWN = auto()
17
+ QUIT = auto()
18
+ KEYDOWN = auto()
19
+ KEYUP = auto()
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class Event:
24
+ """
25
+ Core event type.
26
+
27
+ For now we only care about:
28
+ - type: what happened
29
+ - key: integer key code (e.g. ESC = 27), or None if not applicable
30
+
31
+ :ivar type (EventType): The type of event.
32
+ :ivar key (int | None): The key code associated with the event, if any.
33
+ """
34
+
35
+ type: EventType
36
+ key: int | None = None
37
+
38
+
39
+ class Backend(Protocol):
40
+ """
41
+ Interface that any rendering/input backend must implement.
42
+
43
+ mini-arcade-core only talks to this protocol, never to SDL/pygame directly.
44
+ """
45
+
46
+ def init(self, width: int, height: int, title: str) -> None:
47
+ """
48
+ Initialize the backend and open a window.
49
+
50
+ Should be called once before the main loop.
51
+ """
52
+
53
+ def poll_events(self) -> Iterable[Event]:
54
+ """
55
+ Return all pending events since last call.
56
+
57
+ Concrete backends will translate their native events into core Event objects.
58
+ """
59
+
60
+ def begin_frame(self) -> None:
61
+ """
62
+ Prepare for drawing a new frame (e.g. clear screen).
63
+ """
64
+
65
+ def end_frame(self) -> None:
66
+ """
67
+ Present the frame to the user (swap buffers).
68
+ """
69
+
70
+ def draw_rect(self, x: int, y: int, w: int, h: int) -> None:
71
+ """
72
+ Draw a filled rectangle in some default color.
73
+
74
+ We'll keep this minimal for now; later we can extend with colors/sprites.
75
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.2.3
3
+ Version: 0.3.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=c66IkzZjiyUbTtjQRyf4XyiH6xPS79Ajxeb1OvnVPZA,887
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=j9savb7y3NPgQsiX3xeRTrEadP7xzIpfsekE74s8AAY,1825
5
+ mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
6
+ mini_arcade_core-0.3.1.dist-info/METADATA,sha256=hvVLCE3cMyEOkcuNTrR-ytOj7SYFG8ATUeUiMbZZWKc,8296
7
+ mini_arcade_core-0.3.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ mini_arcade_core-0.3.1.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
+ mini_arcade_core-0.3.1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- mini_arcade_core/__init__.py,sha256=rtRWWmwC-yFNPHCLDI4C7P9i4ZYItDp7TP8i8cBUgmk,795
2
- mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
3
- mini_arcade_core/game.py,sha256=j9savb7y3NPgQsiX3xeRTrEadP7xzIpfsekE74s8AAY,1825
4
- mini_arcade_core/scene.py,sha256=FEtywrnOBU8p0-t8oWGDELYBRRXOs4-Phe0dF7iSjKI,927
5
- mini_arcade_core-0.2.3.dist-info/METADATA,sha256=bK_wXGKvvBIXY0E-KRDuGXK9_gtGoA74blCPZ7qJX-8,8296
6
- mini_arcade_core-0.2.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
7
- mini_arcade_core-0.2.3.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
8
- mini_arcade_core-0.2.3.dist-info/RECORD,,