mini-arcade-core 0.7.1__tar.gz → 0.7.2__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.7.1 → mini_arcade_core-0.7.2}/PKG-INFO +1 -1
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/pyproject.toml +1 -1
- mini_arcade_core-0.7.2/src/mini_arcade_core/scene.py +69 -0
- mini_arcade_core-0.7.1/src/mini_arcade_core/scene.py +0 -40
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/LICENSE +0 -0
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/README.md +0 -0
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/src/mini_arcade_core/__init__.py +0 -0
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/src/mini_arcade_core/backend.py +0 -0
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/src/mini_arcade_core/entity.py +0 -0
- {mini_arcade_core-0.7.1 → mini_arcade_core-0.7.2}/src/mini_arcade_core/game.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.
|
|
7
|
+
version = "0.7.2"
|
|
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" },
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for game scenes (states/screens).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import Callable, List
|
|
9
|
+
|
|
10
|
+
from mini_arcade_core.backend import Backend
|
|
11
|
+
|
|
12
|
+
from .game import Game
|
|
13
|
+
|
|
14
|
+
OverlayFunc = Callable[[Backend], None]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Scene(ABC):
|
|
18
|
+
"""Base class for game scenes (states/screens)."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, game: Game):
|
|
21
|
+
"""
|
|
22
|
+
:param game: Reference to the main Game object.
|
|
23
|
+
:type game: Game
|
|
24
|
+
"""
|
|
25
|
+
self.game = game
|
|
26
|
+
# overlays drawn on top of the scene
|
|
27
|
+
self._overlays: List[OverlayFunc] = []
|
|
28
|
+
|
|
29
|
+
def add_overlay(self, overlay: OverlayFunc) -> None:
|
|
30
|
+
"""Register an overlay (drawn every frame, after entities)."""
|
|
31
|
+
self._overlays.append(overlay)
|
|
32
|
+
|
|
33
|
+
def remove_overlay(self, overlay: OverlayFunc) -> None:
|
|
34
|
+
if overlay in self._overlays:
|
|
35
|
+
self._overlays.remove(overlay)
|
|
36
|
+
|
|
37
|
+
def clear_overlays(self) -> None:
|
|
38
|
+
self._overlays.clear()
|
|
39
|
+
|
|
40
|
+
def draw_overlays(self, surface: Backend) -> None:
|
|
41
|
+
"""Call all overlays. Scenes should call this at the end of draw()."""
|
|
42
|
+
for overlay in self._overlays:
|
|
43
|
+
overlay(surface)
|
|
44
|
+
|
|
45
|
+
@abstractmethod
|
|
46
|
+
def on_enter(self):
|
|
47
|
+
"""Called when the scene becomes active."""
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def on_exit(self):
|
|
51
|
+
"""Called when the scene is replaced."""
|
|
52
|
+
|
|
53
|
+
@abstractmethod
|
|
54
|
+
def handle_event(self, event: object):
|
|
55
|
+
"""Handle input / events (e.g. pygame.Event)."""
|
|
56
|
+
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def update(self, dt: float):
|
|
59
|
+
"""Update game logic. ``dt`` is the delta time in seconds."""
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def draw(self, surface: object):
|
|
63
|
+
"""Render to the main surface."""
|
|
64
|
+
|
|
65
|
+
def draw(self, surface: object):
|
|
66
|
+
"""Render to the main surface."""
|
|
67
|
+
|
|
68
|
+
def draw(self, surface: object):
|
|
69
|
+
"""Render to the main surface."""
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Base class for game scenes (states/screens).
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from abc import ABC, abstractmethod
|
|
8
|
-
|
|
9
|
-
from .game import Game
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Scene(ABC):
|
|
13
|
-
"""Base class for game scenes (states/screens)."""
|
|
14
|
-
|
|
15
|
-
def __init__(self, game: Game):
|
|
16
|
-
"""
|
|
17
|
-
:param game: Reference to the main Game object.
|
|
18
|
-
:type game: Game
|
|
19
|
-
"""
|
|
20
|
-
self.game = game
|
|
21
|
-
|
|
22
|
-
@abstractmethod
|
|
23
|
-
def on_enter(self):
|
|
24
|
-
"""Called when the scene becomes active."""
|
|
25
|
-
|
|
26
|
-
@abstractmethod
|
|
27
|
-
def on_exit(self):
|
|
28
|
-
"""Called when the scene is replaced."""
|
|
29
|
-
|
|
30
|
-
@abstractmethod
|
|
31
|
-
def handle_event(self, event: object):
|
|
32
|
-
"""Handle input / events (e.g. pygame.Event)."""
|
|
33
|
-
|
|
34
|
-
@abstractmethod
|
|
35
|
-
def update(self, dt: float):
|
|
36
|
-
"""Update game logic. ``dt`` is the delta time in seconds."""
|
|
37
|
-
|
|
38
|
-
@abstractmethod
|
|
39
|
-
def draw(self, surface: object):
|
|
40
|
-
"""Render to the main surface."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|