mini-arcade-native-backend 0.5.3__tar.gz → 1.0.0__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 (58) hide show
  1. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/CHANGELOG.md +17 -0
  2. mini_arcade_native_backend-1.0.0/CMakeLists.txt +73 -0
  3. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/PKG-INFO +5 -5
  4. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/README.md +3 -3
  5. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/cpp/bindings.cpp +6 -1
  6. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/cpp/engine.cpp +26 -0
  7. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/cpp/engine.h +3 -0
  8. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/poetry.lock +4 -4
  9. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/pyproject.toml +2 -2
  10. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/__init__.py +60 -0
  11. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/_native.pyi +441 -0
  12. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/config.py +187 -0
  13. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/dlls.py +33 -0
  14. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/mapping/__init__.py +0 -0
  15. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/mapping/events.py +152 -0
  16. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/native_backend.py +127 -0
  17. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/__init__.py +0 -0
  18. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/audio.py +90 -0
  19. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/capture.py +33 -0
  20. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/input.py +41 -0
  21. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/render.py +134 -0
  22. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/text.py +114 -0
  23. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/ports/window.py +69 -0
  24. mini_arcade_native_backend-1.0.0/src/mini_arcade_native_backend/viewport.py +51 -0
  25. mini_arcade_native_backend-1.0.0/src/native/audio.cpp +88 -0
  26. mini_arcade_native_backend-1.0.0/src/native/backend.cpp +53 -0
  27. mini_arcade_native_backend-1.0.0/src/native/bindings.cpp +167 -0
  28. mini_arcade_native_backend-1.0.0/src/native/capture.cpp +30 -0
  29. mini_arcade_native_backend-1.0.0/src/native/include/mini/audio.h +34 -0
  30. mini_arcade_native_backend-1.0.0/src/native/include/mini/backend.h +39 -0
  31. mini_arcade_native_backend-1.0.0/src/native/include/mini/capture.h +12 -0
  32. mini_arcade_native_backend-1.0.0/src/native/include/mini/color.h +8 -0
  33. mini_arcade_native_backend-1.0.0/src/native/include/mini/config.h +45 -0
  34. mini_arcade_native_backend-1.0.0/src/native/include/mini/event.h +45 -0
  35. mini_arcade_native_backend-1.0.0/src/native/include/mini/input.h +14 -0
  36. mini_arcade_native_backend-1.0.0/src/native/include/mini/platform.h +21 -0
  37. mini_arcade_native_backend-1.0.0/src/native/include/mini/renderer.h +35 -0
  38. mini_arcade_native_backend-1.0.0/src/native/include/mini/sdl_renderer.h +43 -0
  39. mini_arcade_native_backend-1.0.0/src/native/include/mini/sdl_text.h +34 -0
  40. mini_arcade_native_backend-1.0.0/src/native/include/mini/text.h +21 -0
  41. mini_arcade_native_backend-1.0.0/src/native/include/mini/window.h +30 -0
  42. mini_arcade_native_backend-1.0.0/src/native/input.cpp +113 -0
  43. mini_arcade_native_backend-1.0.0/src/native/platform.cpp +31 -0
  44. mini_arcade_native_backend-1.0.0/src/native/sdl_renderer.cpp +117 -0
  45. mini_arcade_native_backend-1.0.0/src/native/sdl_text.cpp +80 -0
  46. mini_arcade_native_backend-1.0.0/src/native/window.cpp +66 -0
  47. mini_arcade_native_backend-0.5.3/CMakeLists.txt +0 -30
  48. mini_arcade_native_backend-0.5.3/src/mini_arcade_native_backend/__init__.py +0 -504
  49. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.github/workflows/ci.yml +0 -0
  50. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.github/workflows/create-release-branch.yml +0 -0
  51. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.github/workflows/release-finalize.yml +0 -0
  52. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.github/workflows/release-publish.yml +0 -0
  53. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.gitignore +0 -0
  54. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/.vscode/settings.json +0 -0
  55. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/LICENSE +0 -0
  56. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/examples/native_backend_demo.py +0 -0
  57. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/poetry.toml +0 -0
  58. {mini_arcade_native_backend-0.5.3 → mini_arcade_native_backend-1.0.0}/tests/test_init.py +0 -0
@@ -6,6 +6,23 @@ This project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.0] - 2026-02-03
10
+
11
+ ### Changed
12
+ - Add separation of concerns
13
+
14
+ ### Other
15
+ - Merge release/0.6 into develop
16
+ - Merge branch 'release/0.6' of https://github.com/alexsc6955/mini-arcade-native-backend into release/0.6
17
+
18
+ ## [0.6.0] - 2026-01-23
19
+
20
+ ### Added
21
+ - add draw_line method to Engine and bind it in Python
22
+
23
+ ### Other
24
+ - Merge release/0.5 into develop
25
+
9
26
  ## [0.5.3] - 2026-01-23
10
27
 
11
28
  - Internal changes only.
@@ -0,0 +1,73 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+
3
+ # --- vcpkg toolchain auto-detect (must be BEFORE project()) ---
4
+ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
5
+ if(DEFINED ENV{VCPKG_ROOT})
6
+ set(_VCPKG_TOOLCHAIN "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
7
+ if(EXISTS "${_VCPKG_TOOLCHAIN}")
8
+ set(CMAKE_TOOLCHAIN_FILE "${_VCPKG_TOOLCHAIN}" CACHE FILEPATH "vcpkg toolchain" FORCE)
9
+ endif()
10
+ endif()
11
+ endif()
12
+
13
+ # If something set a broken toolchain like "/scripts/buildsystems/vcpkg.cmake", fix it
14
+ if(DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "^/scripts/buildsystems/vcpkg.cmake$")
15
+ if(DEFINED ENV{VCPKG_ROOT})
16
+ set(_VCPKG_TOOLCHAIN "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
17
+ if(EXISTS "${_VCPKG_TOOLCHAIN}")
18
+ set(CMAKE_TOOLCHAIN_FILE "${_VCPKG_TOOLCHAIN}" CACHE FILEPATH "vcpkg toolchain" FORCE)
19
+ endif()
20
+ endif()
21
+ endif()
22
+
23
+ project(mini_arcade_native_backend LANGUAGES CXX)
24
+
25
+ set(CMAKE_CXX_STANDARD 17)
26
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
27
+
28
+ # Let vcpkg toolchain be used if user sets CMAKE_TOOLCHAIN_FILE env var.
29
+ # (scikit-build-core will pass env vars to CMake.)
30
+
31
+ find_package(pybind11 CONFIG REQUIRED)
32
+ find_package(SDL2 CONFIG REQUIRED)
33
+ find_package(SDL2_ttf CONFIG REQUIRED)
34
+ find_package(SDL2_mixer CONFIG REQUIRED)
35
+
36
+ set(TARGET_NAME _native)
37
+
38
+ set(NATIVE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/native)
39
+ set(NATIVE_INC ${NATIVE_ROOT}/include)
40
+
41
+ set(NATIVE_SOURCES
42
+ ${NATIVE_ROOT}/bindings.cpp
43
+ ${NATIVE_ROOT}/backend.cpp
44
+ ${NATIVE_ROOT}/platform.cpp
45
+ ${NATIVE_ROOT}/window.cpp
46
+ ${NATIVE_ROOT}/input.cpp
47
+ ${NATIVE_ROOT}/capture.cpp
48
+ ${NATIVE_ROOT}/audio.cpp
49
+ ${NATIVE_ROOT}/sdl_renderer.cpp
50
+ ${NATIVE_ROOT}/sdl_text.cpp
51
+ )
52
+
53
+ pybind11_add_module(${TARGET_NAME} ${NATIVE_SOURCES})
54
+
55
+ target_include_directories(${TARGET_NAME}
56
+ PRIVATE
57
+ ${NATIVE_INC}
58
+ )
59
+
60
+ # # C++ sources live under cpp/
61
+ # pybind11_add_module(${TARGET_NAME}
62
+ # cpp/bindings.cpp
63
+ # cpp/engine.cpp
64
+ # )
65
+
66
+ target_link_libraries(${TARGET_NAME} PRIVATE SDL2::SDL2 SDL2_ttf::SDL2_ttf SDL2_mixer::SDL2_mixer)
67
+
68
+ # Install the compiled extension into the Python package directory
69
+ # so it ends up as mini_arcade_native_backend/_native.*.pyd
70
+ install(TARGETS ${TARGET_NAME}
71
+ LIBRARY DESTINATION mini_arcade_native_backend
72
+ RUNTIME DESTINATION mini_arcade_native_backend
73
+ ARCHIVE DESTINATION mini_arcade_native_backend)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mini-arcade-native-backend
3
- Version: 0.5.3
3
+ Version: 1.0.0
4
4
  Summary: Native SDL2 backend for mini-arcade-core using SDL2 + pybind11.
5
5
  Author-Email: Santiago Rincon <rincores@gmail.com>
6
6
  License: Copyright (c) 2025 Santiago Rincón
@@ -24,7 +24,7 @@ License: Copyright (c) 2025 Santiago Rincón
24
24
  SOFTWARE.
25
25
 
26
26
  Requires-Python: <3.12,>=3.9
27
- Requires-Dist: mini-arcade-core~=1.0
27
+ Requires-Dist: mini-arcade-core~=1.1
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: pytest~=8.3; extra == "dev"
30
30
  Requires-Dist: pytest-cov~=6.0; extra == "dev"
@@ -295,14 +295,14 @@ from mini_arcade_core.backend import Backend, Event, EventType
295
295
  from mini_arcade_native_backend import NativeBackend
296
296
 
297
297
  class MyScene(Scene):
298
- def handle_event(self, event: Event) -> None:
298
+ def handle_event(self, event: Event):
299
299
  if event.type == EventType.KEYDOWN and event.key == 27: # ESC
300
300
  self.game.quit()
301
301
 
302
- def update(self, dt: float) -> None:
302
+ def update(self, dt: float):
303
303
  ...
304
304
 
305
- def draw(self, backend: Backend) -> None:
305
+ def draw(self, backend: Backend):
306
306
  backend.draw_rect(100, 100, 200, 150)
307
307
 
308
308
  config = GameConfig(
@@ -259,14 +259,14 @@ from mini_arcade_core.backend import Backend, Event, EventType
259
259
  from mini_arcade_native_backend import NativeBackend
260
260
 
261
261
  class MyScene(Scene):
262
- def handle_event(self, event: Event) -> None:
262
+ def handle_event(self, event: Event):
263
263
  if event.type == EventType.KEYDOWN and event.key == 27: # ESC
264
264
  self.game.quit()
265
265
 
266
- def update(self, dt: float) -> None:
266
+ def update(self, dt: float):
267
267
  ...
268
268
 
269
- def draw(self, backend: Backend) -> None:
269
+ def draw(self, backend: Backend):
270
270
  backend.draw_rect(100, 100, 200, 150)
271
271
 
272
272
  config = GameConfig(
@@ -122,5 +122,10 @@ PYBIND11_MODULE(_native, m) {
122
122
  py::arg("y"),
123
123
  py::arg("w"),
124
124
  py::arg("h"))
125
- .def("clear_clip_rect", &mini::Engine::clear_clip_rect);
125
+ .def("clear_clip_rect", &mini::Engine::clear_clip_rect)
126
+ .def("draw_line", &mini::Engine::draw_line,
127
+ py::arg("x1"), py::arg("y1"),
128
+ py::arg("x2"), py::arg("y2"),
129
+ py::arg("r"), py::arg("g"), py::arg("b"), py::arg("a"));
130
+
126
131
  }
@@ -567,4 +567,30 @@ namespace mini {
567
567
  SDL_RenderSetClipRect(renderer_, nullptr);
568
568
  }
569
569
 
570
+ void Engine::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a)
571
+ {
572
+ if (!initialized_ || renderer_ == nullptr) {
573
+ return;
574
+ }
575
+
576
+ auto clamp = [](int v) {
577
+ if (v < 0) return 0;
578
+ if (v > 255) return 255;
579
+ return v;
580
+ };
581
+
582
+ // alpha or default alpha
583
+ a = (a < 0) ? default_alpha_ : a;
584
+
585
+ SDL_SetRenderDrawColor(
586
+ renderer_,
587
+ static_cast<Uint8>(clamp(r)),
588
+ static_cast<Uint8>(clamp(g)),
589
+ static_cast<Uint8>(clamp(b)),
590
+ static_cast<Uint8>(clamp(a))
591
+ );
592
+
593
+ SDL_RenderDrawLine(renderer_, x1, y1, x2, y2);
594
+ }
595
+
570
596
  } // namespace mini
@@ -123,6 +123,9 @@ namespace mini {
123
123
  // Clear clipping rectangle (disable clipping).
124
124
  void clear_clip_rect();
125
125
 
126
+ // Draw a line from (x1, y1) to (x2, y2) with specified color.
127
+ void draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a);
128
+
126
129
  private:
127
130
  SDL_Window* window_; // The main application window.
128
131
  SDL_Renderer* renderer_; // The renderer for drawing.
@@ -516,14 +516,14 @@ files = [
516
516
 
517
517
  [[package]]
518
518
  name = "mini-arcade-core"
519
- version = "1.0.0"
519
+ version = "1.1.1"
520
520
  description = "Tiny scene-based game loop core for small arcade games."
521
521
  optional = false
522
522
  python-versions = "<3.12,>=3.9"
523
523
  groups = ["main"]
524
524
  files = [
525
- {file = "mini_arcade_core-1.0.0-py3-none-any.whl", hash = "sha256:16ec8b11e6c6c7c6fc414d872d03934f2f7df01b5ffaf8515af98ab081507b07"},
526
- {file = "mini_arcade_core-1.0.0.tar.gz", hash = "sha256:3565073c6f3896a9a23b347745d33ddb374b2cb19b6a4001c31a31f66690923e"},
525
+ {file = "mini_arcade_core-1.1.1-py3-none-any.whl", hash = "sha256:cd487278b33ba77e80acfdc895a77a76cc1d07f5c800a26b7537e18aaa97f00e"},
526
+ {file = "mini_arcade_core-1.1.1.tar.gz", hash = "sha256:b3b81a3adefaaf2b5438bc773ed364a5cf997e7f00a67ef3fc8be9d40bdbc61f"},
527
527
  ]
528
528
 
529
529
  [package.dependencies]
@@ -1001,4 +1001,4 @@ dev = ["black", "isort", "mypy", "pylint", "pytest", "pytest-cov"]
1001
1001
  [metadata]
1002
1002
  lock-version = "2.1"
1003
1003
  python-versions = ">=3.9,<3.12"
1004
- content-hash = "36a9b75ca1c71a10eb85ee901a0df5f279b1433575e1f797b11d5c7efb875e7b"
1004
+ content-hash = "049cf6813d766ae9a7c9ab36a2ef36d24fce8da7a19ffa70200461aef112012d"
@@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build"
8
8
 
9
9
  [project]
10
10
  name = "mini-arcade-native-backend"
11
- version = "0.5.3"
11
+ version = "1.0.0"
12
12
  description = "Native SDL2 backend for mini-arcade-core using SDL2 + pybind11."
13
13
  authors = [
14
14
  { name = "Santiago Rincon", email = "rincores@gmail.com" },
@@ -17,7 +17,7 @@ readme = "README.md"
17
17
  requires-python = ">=3.9,<3.12"
18
18
  license = { file = "LICENSE" }
19
19
  dependencies = [
20
- "mini-arcade-core~=1.0",
20
+ "mini-arcade-core~=1.1",
21
21
  ]
22
22
 
23
23
  [project.optional-dependencies]
@@ -0,0 +1,60 @@
1
+ """
2
+ mini-arcade native backend package.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import TYPE_CHECKING
8
+
9
+ from .dlls import setup_windows_dll_search_paths
10
+
11
+ setup_windows_dll_search_paths()
12
+
13
+ if TYPE_CHECKING:
14
+ # Justification: Need to import core after setting DLL path on Windows
15
+ # pylint: disable=wrong-import-position
16
+ from .config import (
17
+ AudioSettings,
18
+ BackendSettings,
19
+ FontSettings,
20
+ RendererSettings,
21
+ WindowSettings,
22
+ )
23
+ from .native_backend import NativeBackend
24
+
25
+ __all__ = [
26
+ "NativeBackend",
27
+ "BackendSettings",
28
+ "WindowSettings",
29
+ "RendererSettings",
30
+ "FontSettings",
31
+ "AudioSettings",
32
+ ]
33
+
34
+
35
+ # NOTE: Momentary __getattr__ to avoid circular imports for type hints
36
+ # pylint: disable=import-outside-toplevel,possibly-unused-variable
37
+ def __getattr__(name: str):
38
+ if name == "NativeBackend":
39
+ from .native_backend import NativeBackend
40
+
41
+ return NativeBackend
42
+
43
+ if name in {
44
+ "AudioSettings",
45
+ "BackendSettings",
46
+ "FontSettings",
47
+ "RendererSettings",
48
+ "WindowSettings",
49
+ }:
50
+ from .config import (
51
+ AudioSettings,
52
+ BackendSettings,
53
+ FontSettings,
54
+ RendererSettings,
55
+ WindowSettings,
56
+ )
57
+
58
+ return locals()[name]
59
+
60
+ raise AttributeError(name)