mini-arcade-core 0.9.0__tar.gz → 0.9.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.
Files changed (19) hide show
  1. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/PKG-INFO +1 -1
  2. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/pyproject.toml +1 -1
  3. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/__init__.py +3 -0
  4. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/backend.py +6 -2
  5. mini_arcade_core-0.9.1/src/mini_arcade_core/keymaps/sdl.py +98 -0
  6. mini_arcade_core-0.9.1/src/mini_arcade_core/keys.py +160 -0
  7. mini_arcade_core-0.9.1/src/mini_arcade_core/ui/__init__.py +0 -0
  8. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/LICENSE +0 -0
  9. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/README.md +0 -0
  10. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/boundaries2d.py +0 -0
  11. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/collision2d.py +0 -0
  12. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/entity.py +0 -0
  13. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/game.py +0 -0
  14. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/geometry2d.py +0 -0
  15. {mini_arcade_core-0.9.0/src/mini_arcade_core/ui → mini_arcade_core-0.9.1/src/mini_arcade_core/keymaps}/__init__.py +0 -0
  16. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/kinematics2d.py +0 -0
  17. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/physics2d.py +0 -0
  18. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/scene.py +0 -0
  19. {mini_arcade_core-0.9.0 → mini_arcade_core-0.9.1}/src/mini_arcade_core/ui/menu.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.9.0
3
+ Version: 0.9.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.9.0"
7
+ version = "0.9.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" },
@@ -19,6 +19,7 @@ from .collision2d import RectCollider
19
19
  from .entity import Entity, KinematicEntity, SpriteEntity
20
20
  from .game import Game, GameConfig
21
21
  from .geometry2d import Bounds2D, Position2D, Size2D
22
+ from .keys import Key, keymap
22
23
  from .kinematics2d import KinematicData
23
24
  from .physics2d import Velocity2D
24
25
  from .scene import Scene
@@ -69,6 +70,8 @@ __all__ = [
69
70
  "VerticalWrap",
70
71
  "RectSprite",
71
72
  "RectKinematic",
73
+ "Key",
74
+ "keymap",
72
75
  ]
73
76
 
74
77
  PACKAGE_NAME = "mini-arcade-core" # or whatever is in your pyproject.toml
@@ -9,6 +9,8 @@ from dataclasses import dataclass
9
9
  from enum import Enum, auto
10
10
  from typing import Iterable, Optional, Protocol, Tuple, Union
11
11
 
12
+ from .keys import Key
13
+
12
14
  Color = Union[Tuple[int, int, int], Tuple[int, int, int, int]]
13
15
 
14
16
 
@@ -57,7 +59,8 @@ class Event:
57
59
  - key: integer key code (e.g. ESC = 27), or None if not applicable
58
60
 
59
61
  :ivar type (EventType): The type of event.
60
- :ivar key (int | None): The key code associated with the event, if any.
62
+ :ivar key (Key | None): The key associated with the event, if any.
63
+ :ivar key_code (int | None): The key code associated with the event, if any.
61
64
  :ivar scancode (int | None): The hardware scancode of the key, if any.
62
65
  :ivar mod (int | None): Modifier keys bitmask, if any.
63
66
  :ivar repeat (bool | None): Whether this key event is a repeat, if any.
@@ -72,7 +75,8 @@ class Event:
72
75
  """
73
76
 
74
77
  type: EventType
75
- key: Optional[int] = None
78
+ key: Key | None = None # Use Key enum for better clarity
79
+ key_code: Optional[int] = None
76
80
 
77
81
  # Keyboard extras (optional)
78
82
  scancode: Optional[int] = None
@@ -0,0 +1,98 @@
1
+ """
2
+ SDL keymap for mini arcade core.
3
+ Maps SDL keycodes to mini arcade core Key enums.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from mini_arcade_core.keys import Key
9
+
10
+ # SDL keycodes you need (minimal set)
11
+ SDLK_ESCAPE = 27
12
+ SDLK_RETURN = 13
13
+ SDLK_SPACE = 32
14
+ SDLK_TAB = 9
15
+ SDLK_BACKSPACE = 8
16
+
17
+ SDLK_UP = 1073741906
18
+ SDLK_DOWN = 1073741905
19
+ SDLK_LEFT = 1073741904
20
+ SDLK_RIGHT = 1073741903
21
+
22
+ F1 = 1073741882
23
+ F2 = 1073741883
24
+ F3 = 1073741884
25
+ F4 = 1073741885
26
+ F5 = 1073741886
27
+ F6 = 1073741887
28
+ F7 = 1073741888
29
+ F8 = 1073741889
30
+ F9 = 1073741890
31
+ F10 = 1073741891
32
+ F11 = 1073741892
33
+ F12 = 1073741893
34
+
35
+ SDL_KEYCODE_TO_KEY: dict[int, Key] = {
36
+ # Letters
37
+ ord("a"): Key.A,
38
+ ord("b"): Key.B,
39
+ ord("c"): Key.C,
40
+ ord("d"): Key.D,
41
+ ord("e"): Key.E,
42
+ ord("f"): Key.F,
43
+ ord("g"): Key.G,
44
+ ord("h"): Key.H,
45
+ ord("i"): Key.I,
46
+ ord("j"): Key.J,
47
+ ord("k"): Key.K,
48
+ ord("l"): Key.L,
49
+ ord("m"): Key.M,
50
+ ord("n"): Key.N,
51
+ ord("o"): Key.O,
52
+ ord("p"): Key.P,
53
+ ord("q"): Key.Q,
54
+ ord("r"): Key.R,
55
+ ord("s"): Key.S,
56
+ ord("t"): Key.T,
57
+ ord("u"): Key.U,
58
+ ord("v"): Key.V,
59
+ ord("w"): Key.W,
60
+ ord("x"): Key.X,
61
+ ord("y"): Key.Y,
62
+ ord("z"): Key.Z,
63
+ # Arrows
64
+ SDLK_UP: Key.UP,
65
+ SDLK_DOWN: Key.DOWN,
66
+ SDLK_LEFT: Key.LEFT,
67
+ SDLK_RIGHT: Key.RIGHT,
68
+ # Common
69
+ SDLK_ESCAPE: Key.ESCAPE,
70
+ SDLK_SPACE: Key.SPACE,
71
+ SDLK_RETURN: Key.ENTER,
72
+ SDLK_TAB: Key.TAB,
73
+ SDLK_BACKSPACE: Key.BACKSPACE,
74
+ # Numbers
75
+ ord("0"): Key.NUM_0,
76
+ ord("1"): Key.NUM_1,
77
+ ord("2"): Key.NUM_2,
78
+ ord("3"): Key.NUM_3,
79
+ ord("4"): Key.NUM_4,
80
+ ord("5"): Key.NUM_5,
81
+ ord("6"): Key.NUM_6,
82
+ ord("7"): Key.NUM_7,
83
+ ord("8"): Key.NUM_8,
84
+ ord("9"): Key.NUM_9,
85
+ # Function keys
86
+ F1: Key.F1,
87
+ F2: Key.F2,
88
+ F3: Key.F3,
89
+ F4: Key.F4,
90
+ F5: Key.F5,
91
+ F6: Key.F6,
92
+ F7: Key.F7,
93
+ F8: Key.F8,
94
+ F9: Key.F9,
95
+ F10: Key.F10,
96
+ F11: Key.F11,
97
+ F12: Key.F12,
98
+ }
@@ -0,0 +1,160 @@
1
+ """
2
+ Mini Arcade Core key definitions.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from dataclasses import dataclass
8
+ from enum import Enum, auto
9
+
10
+
11
+ class Key(Enum):
12
+ """
13
+ Enumeration of common keyboard keys.
14
+
15
+ :ivar A-Z: Letter keys.
16
+ :ivar arrow_up, arrow_down, arrow_left, arrow_right: Arrow keys.
17
+ :ivar escape, space, enter, tab, backspace: Common control keys.
18
+ :ivar num_0 - num_9: Number keys.
19
+ :ivar f1 - f12: Function keys.
20
+ """
21
+
22
+ # Letters
23
+ A = auto()
24
+ B = auto()
25
+ C = auto()
26
+ D = auto()
27
+ E = auto()
28
+ F = auto()
29
+ G = auto()
30
+ H = auto()
31
+ I = auto()
32
+ J = auto()
33
+ K = auto()
34
+ L = auto()
35
+ M = auto()
36
+ N = auto()
37
+ O = auto()
38
+ P = auto()
39
+ Q = auto()
40
+ R = auto()
41
+ S = auto()
42
+ T = auto()
43
+ U = auto()
44
+ V = auto()
45
+ W = auto()
46
+ X = auto()
47
+ Y = auto()
48
+ Z = auto()
49
+
50
+ # Arrows
51
+ UP = auto()
52
+ DOWN = auto()
53
+ LEFT = auto()
54
+ RIGHT = auto()
55
+
56
+ # Common
57
+ ESCAPE = auto()
58
+ SPACE = auto()
59
+ ENTER = auto()
60
+ TAB = auto()
61
+ BACKSPACE = auto()
62
+
63
+ # Numbers
64
+ NUM_0 = auto()
65
+ NUM_1 = auto()
66
+ NUM_2 = auto()
67
+ NUM_3 = auto()
68
+ NUM_4 = auto()
69
+ NUM_5 = auto()
70
+ NUM_6 = auto()
71
+ NUM_7 = auto()
72
+ NUM_8 = auto()
73
+ NUM_9 = auto()
74
+
75
+ # Function keys
76
+ F1 = auto()
77
+ F2 = auto()
78
+ F3 = auto()
79
+ F4 = auto()
80
+ F5 = auto()
81
+ F6 = auto()
82
+ F7 = auto()
83
+ F8 = auto()
84
+ F9 = auto()
85
+ F10 = auto()
86
+ F11 = auto()
87
+ F12 = auto()
88
+
89
+
90
+ # Justification: Simple alias object for keys
91
+ # pylint: disable=too-many-instance-attributes
92
+ @dataclass(frozen=True)
93
+ class _Keys:
94
+ # alias object so user code can do keys.w, keys.arrow_up, etc.
95
+ a: Key = Key.A
96
+ b: Key = Key.B
97
+ c: Key = Key.C
98
+ d: Key = Key.D
99
+ e: Key = Key.E
100
+ f: Key = Key.F
101
+ g: Key = Key.G
102
+ h: Key = Key.H
103
+ i: Key = Key.I
104
+ j: Key = Key.J
105
+ k: Key = Key.K
106
+ l: Key = Key.L
107
+ m: Key = Key.M
108
+ n: Key = Key.N
109
+ o: Key = Key.O
110
+ p: Key = Key.P
111
+ q: Key = Key.Q
112
+ r: Key = Key.R
113
+ s: Key = Key.S
114
+ t: Key = Key.T
115
+ u: Key = Key.U
116
+ v: Key = Key.V
117
+ w: Key = Key.W
118
+ x: Key = Key.X
119
+ y: Key = Key.Y
120
+ z: Key = Key.Z
121
+
122
+ up: Key = Key.UP
123
+ down: Key = Key.DOWN
124
+ left: Key = Key.LEFT
125
+ right: Key = Key.RIGHT
126
+
127
+ escape: Key = Key.ESCAPE
128
+ space: Key = Key.SPACE
129
+ enter: Key = Key.ENTER
130
+ tab: Key = Key.TAB
131
+ backspace: Key = Key.BACKSPACE
132
+
133
+ num_0: Key = Key.NUM_0
134
+ num_1: Key = Key.NUM_1
135
+ num_2: Key = Key.NUM_2
136
+ num_3: Key = Key.NUM_3
137
+ num_4: Key = Key.NUM_4
138
+ num_5: Key = Key.NUM_5
139
+ num_6: Key = Key.NUM_6
140
+ num_7: Key = Key.NUM_7
141
+ num_8: Key = Key.NUM_8
142
+ num_9: Key = Key.NUM_9
143
+
144
+ f1: Key = Key.F1
145
+ f2: Key = Key.F2
146
+ f3: Key = Key.F3
147
+ f4: Key = Key.F4
148
+ f5: Key = Key.F5
149
+ f6: Key = Key.F6
150
+ f7: Key = Key.F7
151
+ f8: Key = Key.F8
152
+ f9: Key = Key.F9
153
+ f10: Key = Key.F10
154
+ f11: Key = Key.F11
155
+ f12: Key = Key.F12
156
+
157
+
158
+ # pylint: enable=too-many-instance-attributes
159
+
160
+ keymap = _Keys()