batframework 1.0.8a3__tar.gz → 1.0.8a4__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.
- {batframework-1.0.8a3/src/batframework.egg-info → batframework-1.0.8a4}/PKG-INFO +1 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/pyproject.toml +1 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/__init__.py +1 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/animatedSprite.py +49 -55
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/audioManager.py +2 -2
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/cutscene.py +5 -2
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/cutsceneBlocks.py +3 -5
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/dynamicEntity.py +10 -4
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/clickableWidget.py +4 -2
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/constraints/constraints.py +158 -18
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/interactiveWidget.py +1 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/label.py +24 -20
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/root.py +7 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/shape.py +21 -15
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/slider.py +17 -33
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/toggle.py +22 -34
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/widget.py +3 -3
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/particle.py +4 -4
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/resourceManager.py +18 -2
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/scene.py +49 -19
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/sceneManager.py +9 -14
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/scrollingSprite.py +7 -8
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/time.py +32 -27
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/transition.py +23 -10
- batframework-1.0.8a4/src/batFramework/utils.py +120 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4/src/batframework.egg-info}/PKG-INFO +1 -1
- batframework-1.0.8a3/src/batFramework/utils.py +0 -59
- {batframework-1.0.8a3 → batframework-1.0.8a4}/LICENCE +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/README.md +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/setup.cfg +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/action.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/actionContainer.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/camera.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/constants.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/easingController.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/entity.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/enums.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/fontManager.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/__init__.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/button.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/constraints/__init__.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/container.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/debugger.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/dialogueBox.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/draggableWidget.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/image.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/indicator.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/layout.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/meter.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/radioButton.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/style.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/styleManager.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/gui/textInput.py +1 -1
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/manager.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/object.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/renderGroup.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/sprite.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/stateMachine.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/tileset.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batFramework/triggerZone.py +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batframework.egg-info/SOURCES.txt +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batframework.egg-info/dependency_links.txt +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batframework.egg-info/requires.txt +0 -0
- {batframework-1.0.8a3 → batframework-1.0.8a4}/src/batframework.egg-info/top_level.txt +0 -0
@@ -8,7 +8,7 @@ from .resourceManager import ResourceManager
|
|
8
8
|
from .fontManager import FontManager
|
9
9
|
from .utils import Utils as utils
|
10
10
|
from .tileset import Tileset
|
11
|
-
from .time import
|
11
|
+
from .time import *
|
12
12
|
from .easingController import EasingController
|
13
13
|
from .cutscene import Cutscene, CutsceneManager
|
14
14
|
from .cutsceneBlocks import *
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import batFramework as bf
|
2
2
|
import pygame
|
3
|
+
from typing import List, Dict, Tuple, Union, Optional
|
4
|
+
from enum import Enum
|
3
5
|
|
4
6
|
|
5
|
-
def search_index(target, lst):
|
7
|
+
def search_index(target: int, lst: List[int]) -> int:
|
6
8
|
cumulative_sum = 0
|
7
9
|
for index, value in enumerate(lst):
|
8
10
|
cumulative_sum += value
|
@@ -16,37 +18,34 @@ class AnimState:
|
|
16
18
|
self,
|
17
19
|
name: str,
|
18
20
|
surface: pygame.Surface,
|
19
|
-
|
20
|
-
|
21
|
-
duration_list: list | int,
|
21
|
+
size: Tuple[int,int],
|
22
|
+
duration_list: Union[List[int], int],
|
22
23
|
) -> None:
|
23
|
-
self.frames:
|
24
|
+
self.frames: List[pygame.Surface] = list(
|
24
25
|
bf.utils.split_surface(
|
25
|
-
surface,
|
26
|
+
surface, size
|
26
27
|
).values()
|
27
28
|
)
|
28
|
-
self.frames_flipX:
|
29
|
-
bf.utils.split_surface(surface,
|
29
|
+
self.frames_flipX: List[pygame.Surface] = list(
|
30
|
+
bf.utils.split_surface(surface, size,).values()
|
30
31
|
)
|
31
32
|
|
32
33
|
self.name = name
|
33
|
-
self.duration_list: list[int] = []
|
34
|
-
self.duration_list_length = 0
|
35
34
|
self.set_duration_list(duration_list)
|
36
35
|
|
37
36
|
def __repr__(self):
|
38
37
|
return f"AnimState({self.name})"
|
39
38
|
|
40
|
-
def counter_to_frame(self, counter: float
|
39
|
+
def counter_to_frame(self, counter: Union[float, int]) -> int:
|
41
40
|
return search_index(
|
42
41
|
int(counter % self.duration_list_length), self.duration_list
|
43
42
|
)
|
44
43
|
|
45
|
-
def get_frame(self, counter, flip):
|
44
|
+
def get_frame(self, counter: Union[float, int], flip: bool) -> pygame.Surface:
|
46
45
|
i = self.counter_to_frame(counter)
|
47
46
|
return self.frames_flipX[i] if flip else self.frames[i]
|
48
47
|
|
49
|
-
def set_duration_list(self, duration_list:
|
48
|
+
def set_duration_list(self, duration_list: Union[List[int], int]):
|
50
49
|
if isinstance(duration_list, int):
|
51
50
|
duration_list = [duration_list] * len(self.frames)
|
52
51
|
if len(duration_list) != len(self.frames):
|
@@ -55,21 +54,23 @@ class AnimState:
|
|
55
54
|
self.duration_list_length = sum(self.duration_list)
|
56
55
|
|
57
56
|
|
58
|
-
class AnimatedSprite(bf.
|
59
|
-
def __init__(self, size=None) -> None:
|
57
|
+
class AnimatedSprite(bf.Entity):
|
58
|
+
def __init__(self, size: Optional[Tuple[int, int]] = None) -> None:
|
60
59
|
super().__init__(size, no_surface=True)
|
61
60
|
self.float_counter: float = 0
|
62
|
-
self.animStates:
|
63
|
-
self.current_state: AnimState
|
64
|
-
self.flipX = False
|
65
|
-
self._locked = False
|
66
|
-
self.
|
61
|
+
self.animStates: Dict[str, AnimState] = {}
|
62
|
+
self.current_state: Optional[AnimState] = None
|
63
|
+
self.flipX: bool = False
|
64
|
+
self._locked: bool = False
|
65
|
+
self._paused: bool = False
|
67
66
|
|
68
|
-
|
69
|
-
|
67
|
+
@property
|
68
|
+
def paused(self) -> bool:
|
69
|
+
return self._paused
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
@paused.setter
|
72
|
+
def paused(self, value: bool) -> None:
|
73
|
+
self._paused = value
|
73
74
|
|
74
75
|
def toggle_pause(self) -> None:
|
75
76
|
self.paused = not self.paused
|
@@ -80,16 +81,7 @@ class AnimatedSprite(bf.DynamicEntity):
|
|
80
81
|
def set_frame(self, frame_index: int) -> None:
|
81
82
|
if not self.current_state:
|
82
83
|
return
|
83
|
-
|
84
|
-
frame_index = max(0, min(total, frame_index))
|
85
|
-
new_counter = 0
|
86
|
-
i = 0
|
87
|
-
while frame_index < total:
|
88
|
-
if self.current_state.counter_to_frame(new_counter) >= frame_index:
|
89
|
-
break
|
90
|
-
new_counter += self.current_state.duration_list[i]
|
91
|
-
i += 1
|
92
|
-
self.set_counter(new_counter)
|
84
|
+
self.set_counter(sum(self.current_state.duration_list[:frame_index]))
|
93
85
|
|
94
86
|
def lock(self) -> None:
|
95
87
|
self._locked = True
|
@@ -97,16 +89,16 @@ class AnimatedSprite(bf.DynamicEntity):
|
|
97
89
|
def unlock(self) -> None:
|
98
90
|
self._locked = False
|
99
91
|
|
100
|
-
def set_flipX(self, value) -> None:
|
92
|
+
def set_flipX(self, value: bool) -> None:
|
101
93
|
self.flipX = value
|
102
94
|
|
103
95
|
def remove_animState(self, name: str) -> bool:
|
104
|
-
if not
|
96
|
+
if name not in self.animStates:
|
105
97
|
return False
|
106
98
|
self.animStates.pop(name)
|
107
99
|
if self.current_state and self.current_state.name == name:
|
108
|
-
self.
|
109
|
-
list(self.animStates.
|
100
|
+
self.current_state = (
|
101
|
+
list(self.animStates.values())[0] if self.animStates else None
|
110
102
|
)
|
111
103
|
return True
|
112
104
|
|
@@ -114,54 +106,56 @@ class AnimatedSprite(bf.DynamicEntity):
|
|
114
106
|
self,
|
115
107
|
name: str,
|
116
108
|
surface: pygame.Surface,
|
117
|
-
size:
|
118
|
-
duration_list:
|
119
|
-
convert_alpha: bool = True,
|
109
|
+
size: Tuple[int, int],
|
110
|
+
duration_list: Union[List[int], int],
|
120
111
|
) -> bool:
|
121
112
|
if name in self.animStates:
|
122
113
|
return False
|
123
|
-
self.animStates[name] = AnimState(
|
114
|
+
self.animStates[name] = AnimState(
|
115
|
+
name, surface, size, duration_list
|
116
|
+
)
|
124
117
|
if len(self.animStates) == 1:
|
125
118
|
self.set_animState(name)
|
126
119
|
return True
|
127
120
|
|
128
|
-
def set_animState(
|
121
|
+
def set_animState(
|
122
|
+
self, state: str, reset_counter: bool = True, lock: bool = False
|
123
|
+
) -> bool:
|
129
124
|
if state not in self.animStates or self._locked:
|
130
125
|
return False
|
131
126
|
|
132
127
|
animState = self.animStates[state]
|
133
128
|
self.current_state = animState
|
134
129
|
|
135
|
-
self.rect = self.current_state.frames[0].
|
130
|
+
self.rect = self.current_state.frames[0].get_rect(center=self.rect.center)
|
136
131
|
|
137
|
-
if reset_counter or self.float_counter >
|
132
|
+
if reset_counter or self.float_counter > animState.duration_list_length:
|
138
133
|
self.float_counter = 0
|
139
134
|
if lock:
|
140
135
|
self.lock()
|
141
136
|
return True
|
142
137
|
|
143
|
-
def get_animState(self) -> AnimState
|
138
|
+
def get_animState(self) -> Optional[AnimState]:
|
144
139
|
return self.current_state
|
145
140
|
|
146
141
|
def update(self, dt: float) -> None:
|
147
142
|
s = self.get_animState()
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
self.float_counter = 0
|
143
|
+
if self.animStates and s is not None:
|
144
|
+
if not self.paused:
|
145
|
+
self.float_counter += 60 * dt
|
146
|
+
if self.float_counter > s.duration_list_length:
|
147
|
+
self.float_counter = 0
|
154
148
|
self.do_update(dt)
|
155
149
|
|
156
|
-
def draw(self, camera: bf.Camera) ->
|
150
|
+
def draw(self, camera: bf.Camera) -> None:
|
157
151
|
if (
|
158
152
|
not self.visible
|
159
153
|
or not camera.rect.colliderect(self.rect)
|
160
154
|
or not self.current_state
|
161
155
|
):
|
162
|
-
return
|
156
|
+
return
|
163
157
|
camera.surface.blit(
|
164
158
|
self.current_state.get_frame(self.float_counter, self.flipX),
|
165
159
|
camera.world_to_screen(self.rect),
|
166
160
|
)
|
167
|
-
return
|
161
|
+
return
|
@@ -68,7 +68,7 @@ class AudioManager(metaclass=bf.Singleton):
|
|
68
68
|
self.sounds[name]["sound"].play()
|
69
69
|
return True
|
70
70
|
except KeyError:
|
71
|
-
|
71
|
+
print(f"Sound '{name}' not loaded in AudioManager.")
|
72
72
|
return False
|
73
73
|
|
74
74
|
def stop_sound(self, name) -> bool:
|
@@ -77,7 +77,7 @@ class AudioManager(metaclass=bf.Singleton):
|
|
77
77
|
return True
|
78
78
|
except KeyError:
|
79
79
|
return False
|
80
|
-
|
80
|
+
print(f"Sound '{name}' not loaded in AudioManager.")
|
81
81
|
|
82
82
|
def load_music(self, name, path):
|
83
83
|
self.musics[name] = bf.ResourceManager().get_path(path)
|
@@ -1,8 +1,11 @@
|
|
1
1
|
import batFramework as bf
|
2
|
-
|
2
|
+
from typing import TYPE_CHECKING
|
3
3
|
|
4
4
|
class CutsceneBlock: ...
|
5
5
|
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from .cutsceneBlocks import CutsceneBlock
|
8
|
+
|
6
9
|
|
7
10
|
class Cutscene: ...
|
8
11
|
|
@@ -58,7 +61,7 @@ class CutsceneManager(metaclass=bf.Singleton):
|
|
58
61
|
|
59
62
|
class Cutscene:
|
60
63
|
def __init__(self) -> None:
|
61
|
-
self.cutscene_blocks = []
|
64
|
+
self.cutscene_blocks : list[CutsceneBlock] = []
|
62
65
|
self.block_index = 0
|
63
66
|
self.end_blocks: list[CutsceneBlock] = []
|
64
67
|
self.ended = False
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import batFramework as bf
|
2
2
|
from .cutscene import Cutscene, CutsceneManager
|
3
3
|
from .transition import *
|
4
|
-
|
4
|
+
from typing import Optional,Callable
|
5
5
|
|
6
6
|
# Define the base CutsceneBlock class
|
7
7
|
class CutsceneBlock:
|
@@ -150,7 +150,6 @@ class SceneTransitionBlock(CutsceneBlock):
|
|
150
150
|
# Start the timer to handle the end of the transition
|
151
151
|
self.timer.start()
|
152
152
|
|
153
|
-
|
154
153
|
class DelayBlock(CutsceneBlock):
|
155
154
|
def __init__(self, duration) -> None:
|
156
155
|
super().__init__()
|
@@ -160,12 +159,11 @@ class DelayBlock(CutsceneBlock):
|
|
160
159
|
super().start()
|
161
160
|
self.timer.start()
|
162
161
|
|
163
|
-
|
164
162
|
class FunctionBlock(CutsceneBlock):
|
165
|
-
def __init__(self, func) -> None:
|
163
|
+
def __init__(self, func : Optional[Callable]) -> None:
|
166
164
|
self.function = func
|
167
165
|
|
168
166
|
def start(self):
|
169
167
|
super().start()
|
170
|
-
self.function()
|
168
|
+
if self.function : self.function()
|
171
169
|
self.end()
|
@@ -8,15 +8,21 @@ class DynamicEntity(bf.Entity):
|
|
8
8
|
self,
|
9
9
|
size: None | tuple[int, int] = None,
|
10
10
|
surface_flags: int = 0,
|
11
|
-
convert_alpha: bool = False
|
11
|
+
convert_alpha: bool = False,*args,**kwargs
|
12
12
|
) -> None:
|
13
|
-
super().__init__(size, surface_flags, convert_alpha)
|
13
|
+
super().__init__(size, surface_flags, convert_alpha,*args,**kwargs)
|
14
14
|
self.velocity = pygame.math.Vector2(0, 0)
|
15
15
|
|
16
|
-
def on_collideX(self, collider:
|
16
|
+
def on_collideX(self, collider: "DynamicEntity"):
|
17
|
+
"""
|
18
|
+
Return true if collision
|
19
|
+
"""
|
17
20
|
return False
|
18
21
|
|
19
|
-
def on_collideY(self, collider:
|
22
|
+
def on_collideY(self, collider: "DynamicEntity"):
|
23
|
+
"""
|
24
|
+
Return true if collision
|
25
|
+
"""
|
20
26
|
return False
|
21
27
|
|
22
28
|
def move_by_velocity(self, dt) -> None:
|
@@ -141,7 +141,8 @@ class ClickableWidget(Shape, InteractiveWidget):
|
|
141
141
|
if not self.get_focus():
|
142
142
|
return
|
143
143
|
self.is_pressed = True
|
144
|
-
|
144
|
+
if self.click_down_sound:
|
145
|
+
bf.AudioManager().play_sound(self.click_down_sound)
|
145
146
|
|
146
147
|
pygame.mouse.set_cursor(self.click_cursor)
|
147
148
|
self.set_relief(self.pressed_relief)
|
@@ -149,7 +150,8 @@ class ClickableWidget(Shape, InteractiveWidget):
|
|
149
150
|
def do_on_click_up(self, button) -> None:
|
150
151
|
if self.enabled and button == 1 and self.is_pressed:
|
151
152
|
self.is_pressed = False
|
152
|
-
|
153
|
+
if self.click_up_sound:
|
154
|
+
bf.AudioManager().play_sound(self.click_up_sound)
|
153
155
|
self.set_relief(self.unpressed_relief)
|
154
156
|
self.click()
|
155
157
|
|