batframework 1.0.8a9__py3-none-any.whl → 1.0.8a10__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.
- batFramework/__init__.py +68 -51
- batFramework/action.py +126 -99
- batFramework/actionContainer.py +53 -9
- batFramework/animatedSprite.py +141 -82
- batFramework/audioManager.py +69 -26
- batFramework/camera.py +259 -69
- batFramework/character.py +27 -0
- batFramework/constants.py +16 -54
- batFramework/cutscene.py +39 -29
- batFramework/cutsceneBlocks.py +36 -43
- batFramework/dynamicEntity.py +18 -9
- batFramework/easingController.py +58 -0
- batFramework/entity.py +48 -97
- batFramework/enums.py +113 -0
- batFramework/fontManager.py +65 -0
- batFramework/gui/__init__.py +10 -2
- batFramework/gui/button.py +9 -78
- batFramework/gui/clickableWidget.py +220 -0
- batFramework/gui/constraints/__init__.py +1 -0
- batFramework/gui/constraints/constraints.py +815 -0
- batFramework/gui/container.py +174 -32
- batFramework/gui/debugger.py +131 -43
- batFramework/gui/dialogueBox.py +99 -0
- batFramework/gui/draggableWidget.py +40 -0
- batFramework/gui/image.py +56 -20
- batFramework/gui/indicator.py +38 -21
- batFramework/gui/interactiveWidget.py +192 -13
- batFramework/gui/label.py +309 -74
- batFramework/gui/layout.py +231 -63
- batFramework/gui/meter.py +74 -0
- batFramework/gui/radioButton.py +84 -0
- batFramework/gui/root.py +134 -38
- batFramework/gui/shape.py +237 -57
- batFramework/gui/slider.py +240 -0
- batFramework/gui/style.py +10 -0
- batFramework/gui/styleManager.py +48 -0
- batFramework/gui/textInput.py +247 -0
- batFramework/gui/toggle.py +101 -51
- batFramework/gui/widget.py +358 -250
- batFramework/manager.py +52 -19
- batFramework/object.py +123 -0
- batFramework/particle.py +115 -0
- batFramework/renderGroup.py +67 -0
- batFramework/resourceManager.py +100 -0
- batFramework/scene.py +281 -123
- batFramework/sceneManager.py +178 -116
- batFramework/scrollingSprite.py +114 -0
- batFramework/sprite.py +51 -0
- batFramework/stateMachine.py +11 -8
- batFramework/templates/__init__.py +2 -0
- batFramework/templates/character.py +44 -0
- batFramework/templates/states.py +166 -0
- batFramework/tileset.py +46 -0
- batFramework/time.py +145 -58
- batFramework/transition.py +195 -124
- batFramework/triggerZone.py +1 -1
- batFramework/utils.py +112 -147
- batframework-1.0.8a10.dist-info/LICENCE +21 -0
- batframework-1.0.8a10.dist-info/METADATA +43 -0
- batframework-1.0.8a10.dist-info/RECORD +62 -0
- batFramework/debugger.py +0 -48
- batFramework/easing.py +0 -71
- batFramework/gui/constraints.py +0 -204
- batFramework/gui/frame.py +0 -19
- batFramework/particles.py +0 -77
- batFramework/transitionManager.py +0 -0
- batframework-1.0.8a9.dist-info/METADATA +0 -53
- batframework-1.0.8a9.dist-info/RECORD +0 -42
- {batframework-1.0.8a9.dist-info → batframework-1.0.8a10.dist-info}/WHEEL +0 -0
- {batframework-1.0.8a9.dist-info → batframework-1.0.8a10.dist-info}/top_level.txt +0 -0
batFramework/camera.py
CHANGED
@@ -1,123 +1,313 @@
|
|
1
|
-
import batFramework as bf
|
2
1
|
import pygame
|
3
2
|
from pygame.math import Vector2
|
3
|
+
import batFramework as bf
|
4
|
+
from typing import Self
|
5
|
+
import math
|
4
6
|
|
5
7
|
|
6
8
|
class Camera:
|
7
|
-
def __init__(
|
8
|
-
self
|
9
|
-
|
10
|
-
|
9
|
+
def __init__(
|
10
|
+
self, flags=0, size: tuple[int, int] | None = None, convert_alpha: bool = False
|
11
|
+
) -> None:
|
12
|
+
"""
|
13
|
+
Initialize the Camera object.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
flags (int): Flags for camera initialization.
|
17
|
+
size (tuple): Optional size for camera (defaults to window size)
|
18
|
+
convert_alpha (bool): Convert surface to support alpha values
|
19
|
+
"""
|
20
|
+
self.cached_surfaces: dict[tuple[int, int], pygame.Surface] = {}
|
21
|
+
|
22
|
+
self.target_size = size if size else bf.const.RESOLUTION
|
23
|
+
self.should_convert_alpha: bool = convert_alpha
|
24
|
+
self.rect = pygame.FRect(0, 0, *self.target_size)
|
25
|
+
self.vector_center = Vector2(0, 0)
|
26
|
+
|
27
|
+
self.surface: pygame.Surface = pygame.Surface((0, 0)) # tmp dummy
|
28
|
+
self.flags: int = flags | (pygame.SRCALPHA if convert_alpha else 0)
|
11
29
|
self.blit_special_flags: int = pygame.BLEND_ALPHA_SDL2
|
12
|
-
|
13
|
-
self.
|
14
|
-
|
15
|
-
|
30
|
+
|
31
|
+
self._clear_color: pygame.Color = pygame.Color(0, 0, 0, 0)
|
32
|
+
if not convert_alpha:
|
33
|
+
self._clear_color = pygame.Color(0, 0, 0)
|
34
|
+
|
16
35
|
self.follow_point_func = None
|
36
|
+
self.damping = float("inf")
|
37
|
+
self.dead_zone_radius = 10
|
38
|
+
|
39
|
+
self.zoom_factor = 1
|
17
40
|
self.max_zoom = 2
|
18
41
|
self.min_zoom = 0.1
|
19
42
|
self.zoom(1)
|
20
43
|
|
21
|
-
def set_clear_color(self, color: pygame.Color|tuple):
|
22
|
-
|
23
|
-
|
44
|
+
def set_clear_color(self, color: pygame.Color | tuple | str) -> Self:
|
45
|
+
"""
|
46
|
+
Set the clear color for the camera surface.
|
47
|
+
|
48
|
+
Args:
|
49
|
+
color (pygame.Color | tuple): Color to set as the clear color.
|
50
|
+
|
51
|
+
Returns:
|
52
|
+
Camera: Returns the Camera object.
|
53
|
+
"""
|
24
54
|
self._clear_color = color
|
55
|
+
return self
|
25
56
|
|
26
|
-
def set_max_zoom(self,value:float):
|
57
|
+
def set_max_zoom(self, value: float) -> Self:
|
58
|
+
"""
|
59
|
+
Set the maximum zoom value for the camera.
|
60
|
+
|
61
|
+
Args:
|
62
|
+
value (float): Maximum zoom value.
|
63
|
+
|
64
|
+
Returns:
|
65
|
+
Camera: Returns the Camera object.
|
66
|
+
"""
|
27
67
|
self.max_zoom = value
|
68
|
+
return self
|
69
|
+
|
70
|
+
def set_min_zoom(self, value: float) -> Self:
|
71
|
+
"""
|
72
|
+
Set the minimum zoom value for the camera.
|
73
|
+
|
74
|
+
Args:
|
75
|
+
value (float): Minimum zoom value.
|
28
76
|
|
29
|
-
|
77
|
+
Returns:
|
78
|
+
Camera: Returns the Camera object.
|
79
|
+
"""
|
30
80
|
self.min_zoom = value
|
81
|
+
return self
|
31
82
|
|
32
|
-
def clear(self):
|
83
|
+
def clear(self) -> None:
|
33
84
|
"""
|
34
|
-
Clear the camera surface with the set clear color
|
35
|
-
(default is tranparent)
|
85
|
+
Clear the camera surface with the set clear color.
|
36
86
|
"""
|
37
87
|
self.surface.fill(self._clear_color)
|
38
88
|
|
39
|
-
def get_center(self):
|
89
|
+
def get_center(self) -> tuple[float, float]:
|
90
|
+
"""
|
91
|
+
Get the center of the camera's view.
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
tuple[float,float]: Returns the center coordinates.
|
95
|
+
"""
|
40
96
|
return self.rect.center
|
41
97
|
|
42
|
-
|
98
|
+
def get_position(self) -> tuple[float, float]:
|
99
|
+
"""
|
100
|
+
Get the center of the camera's view.
|
43
101
|
|
44
|
-
|
102
|
+
Returns:
|
103
|
+
tuple[float,float]: Returns the center coordinates.
|
45
104
|
"""
|
46
|
-
|
105
|
+
return self.rect.topleft
|
106
|
+
|
107
|
+
def move_by(self, x: float | int, y: float | int) -> Self:
|
47
108
|
"""
|
48
|
-
|
109
|
+
Moves the camera rect by the given coordinates.
|
110
|
+
|
111
|
+
Args:
|
112
|
+
x: X-coordinate to move.
|
113
|
+
y: Y-coordinate to move.
|
49
114
|
|
50
|
-
|
115
|
+
Returns:
|
116
|
+
Camera: Returns the Camera object.
|
51
117
|
"""
|
52
|
-
|
118
|
+
self.rect.move_ip(x, y)
|
119
|
+
return self
|
120
|
+
|
121
|
+
def set_position(self, x, y) -> Self:
|
122
|
+
"""
|
123
|
+
Set the camera rect top-left position.
|
124
|
+
|
125
|
+
Args:
|
126
|
+
x: X-coordinate to set.
|
127
|
+
y: Y-coordinate to set.
|
128
|
+
|
129
|
+
Returns:
|
130
|
+
Camera: Returns the Camera object.
|
53
131
|
"""
|
54
132
|
self.rect.topleft = (x, y)
|
55
133
|
|
56
|
-
|
134
|
+
return self
|
135
|
+
|
136
|
+
def set_center(self, x, y) -> Self:
|
57
137
|
"""
|
58
|
-
Set the camera rect center position
|
138
|
+
Set the camera rect center position.
|
139
|
+
|
140
|
+
Args:
|
141
|
+
x: X-coordinate for the center.
|
142
|
+
y: Y-coordinate for the center.
|
143
|
+
|
144
|
+
Returns:
|
145
|
+
Camera: Returns the Camera object.
|
59
146
|
"""
|
60
147
|
self.rect.center = (x, y)
|
148
|
+
return self
|
149
|
+
|
150
|
+
def set_follow_point_func(self, func) -> Self:
|
151
|
+
self.follow_point_func = func
|
152
|
+
return self
|
153
|
+
|
154
|
+
def set_follow_speed(self, speed: float) -> Self:
|
155
|
+
self.follow_speed = speed
|
156
|
+
return self
|
157
|
+
|
158
|
+
def set_follow_damping(self, damping: float) -> Self:
|
159
|
+
self.damping = damping
|
160
|
+
return self
|
161
|
+
|
162
|
+
def set_dead_zone_radius(self, radius: float) -> Self:
|
163
|
+
self.dead_zone_radius = radius
|
164
|
+
return self
|
61
165
|
|
62
|
-
def
|
166
|
+
def zoom_by(self, amount: float) -> Self:
|
63
167
|
"""
|
64
|
-
|
65
|
-
|
168
|
+
Zooms the camera by the given amount.
|
169
|
+
|
170
|
+
Args:
|
171
|
+
amount (float): Amount to zoom.
|
172
|
+
|
173
|
+
Returns:
|
174
|
+
Camera: Returns the Camera object.
|
66
175
|
"""
|
67
|
-
self.
|
176
|
+
self.zoom(max(self.min_zoom, min(self.max_zoom, self.zoom_factor + amount)))
|
177
|
+
return self
|
68
178
|
|
69
|
-
def
|
70
|
-
|
179
|
+
def zoom(self, factor: float) -> Self:
|
180
|
+
"""
|
181
|
+
Zooms the camera to the given factor.
|
71
182
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
183
|
+
Args:
|
184
|
+
factor: Factor to set for zooming.
|
185
|
+
|
186
|
+
Returns:
|
187
|
+
Camera: Returns the Camera object.
|
188
|
+
"""
|
189
|
+
if factor < self.min_zoom or factor > self.max_zoom:
|
190
|
+
print(
|
191
|
+
f"Zoom value {factor} is outside the zoom range : [{self.min_zoom},{self.max_zoom}]"
|
192
|
+
)
|
193
|
+
return self
|
194
|
+
|
195
|
+
factor = round(factor, 2)
|
78
196
|
self.zoom_factor = factor
|
79
|
-
|
80
|
-
|
81
|
-
self.cached_surfaces[factor] = pygame.Surface(
|
82
|
-
tuple(i / factor for i in bf.const.RESOLUTION), flags=self.flags
|
83
|
-
).convert_alpha()
|
84
|
-
# c = self.surface.get_colorkey() if self.surface else None
|
85
|
-
# if c : self.cached_surfaces[factor].set_colorkey(c)
|
86
|
-
self.cached_surfaces[factor].fill((0, 0, 0, 0))
|
87
|
-
|
88
|
-
self.surface = self.cached_surfaces[self.zoom_factor]
|
197
|
+
new_res = tuple(round((i / factor) / 2) * 2 for i in self.target_size)
|
198
|
+
self.surface = self._get_cached_surface(new_res)
|
89
199
|
self.rect = self.surface.get_frect(center=self.rect.center)
|
90
|
-
|
200
|
+
self.clear()
|
201
|
+
return self
|
202
|
+
|
203
|
+
def _free_cache(self):
|
204
|
+
self.cached_surfaces = {}
|
205
|
+
|
206
|
+
def _get_cached_surface(self, new_size: tuple[int, int]):
|
207
|
+
surface = self.cached_surfaces.get(new_size, None)
|
208
|
+
if surface is None:
|
209
|
+
surface = pygame.Surface(new_size, flags=self.flags)
|
210
|
+
if self.flags & pygame.SRCALPHA:
|
211
|
+
surface = surface.convert_alpha()
|
212
|
+
self.cached_surfaces[new_size] = surface
|
213
|
+
|
214
|
+
return surface
|
215
|
+
|
216
|
+
def resize(self, size: tuple[int, int] | None = None) -> Self:
|
217
|
+
if size is None:
|
218
|
+
size = bf.const.RESOLUTION
|
219
|
+
self.target_size = size
|
220
|
+
self.rect.center = (size[0] / 2, size[1] / 2)
|
221
|
+
self.zoom(self.zoom_factor)
|
222
|
+
|
223
|
+
return self
|
91
224
|
|
92
225
|
def intersects(self, rect: pygame.Rect | pygame.FRect) -> bool:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
226
|
+
"""
|
227
|
+
Check if the camera view intersects with the given rectangle.
|
228
|
+
|
229
|
+
Args:
|
230
|
+
rect (pygame.Rect | pygame.FRect): Rectangle to check intersection with.
|
231
|
+
|
232
|
+
Returns:
|
233
|
+
bool: True if intersection occurs, False otherwise.
|
234
|
+
"""
|
235
|
+
return self.rect.colliderect(rect)
|
236
|
+
|
237
|
+
def world_to_screen(
|
238
|
+
self, rect: pygame.Rect | pygame.FRect
|
239
|
+
) -> pygame.Rect | pygame.FRect:
|
240
|
+
"""
|
241
|
+
world_to_screen the given rectangle coordinates relative to the camera.
|
242
|
+
|
243
|
+
Args:
|
244
|
+
rect (pygame.Rect | pygame.FRect): Rectangle to world_to_screen.
|
245
|
+
|
246
|
+
Returns:
|
247
|
+
pygame.FRect: Transposed rectangle.
|
248
|
+
"""
|
249
|
+
return pygame.FRect(
|
250
|
+
rect[0] - self.rect.left, rect[1] - self.rect.top, rect[2], rect[3]
|
98
251
|
)
|
99
252
|
|
253
|
+
def world_to_screen_point(
|
254
|
+
self, point: tuple[float, float] | tuple[int, int]
|
255
|
+
) -> tuple[float, float]:
|
256
|
+
"""
|
257
|
+
world_to_screen the given 2D point coordinates relative to the camera.
|
258
|
+
|
259
|
+
Args:
|
260
|
+
point (tuple[float,float] | tuple[int,int]): Point to world_to_screen.
|
100
261
|
|
101
|
-
|
102
|
-
|
103
|
-
|
262
|
+
Returns:
|
263
|
+
tuple[float,float] : Transposed point.
|
264
|
+
"""
|
265
|
+
return point[0] - self.rect.x, point[1] - self.rect.y
|
266
|
+
|
267
|
+
def screen_to_world(
|
268
|
+
self, point: tuple[float, float] | tuple[int, int]
|
269
|
+
) -> tuple[float, float]:
|
270
|
+
"""
|
271
|
+
Convert screen coordinates to world coordinates based on camera settings.
|
104
272
|
|
105
|
-
|
106
|
-
|
273
|
+
Args:
|
274
|
+
point (tuple[float,float] | tuple[int,int]): Point to screen_to_world.
|
275
|
+
Returns:
|
276
|
+
tuple: Converted world coordinates.
|
277
|
+
"""
|
278
|
+
return (
|
279
|
+
point[0] / self.zoom_factor + self.rect.x,
|
280
|
+
point[1] / self.zoom_factor + self.rect.y,
|
281
|
+
)
|
107
282
|
|
108
283
|
def update(self, dt):
|
109
|
-
if self.follow_point_func:
|
110
|
-
|
111
|
-
|
284
|
+
if not self.follow_point_func or not (math.isfinite(dt) and dt > 0):
|
285
|
+
return
|
286
|
+
|
287
|
+
target = Vector2(self.follow_point_func())
|
288
|
+
self.vector_center.update(self.rect.center)
|
289
|
+
|
290
|
+
if self.damping == float("inf"):
|
291
|
+
self.vector_center = target
|
292
|
+
elif math.isfinite(self.damping) and self.damping > 0:
|
293
|
+
damping_factor = 1 - math.exp(-self.damping * dt)
|
294
|
+
if not math.isnan(damping_factor):
|
295
|
+
self.vector_center += (target - self.vector_center) * damping_factor
|
296
|
+
|
297
|
+
self.rect.center = self.vector_center
|
112
298
|
|
113
299
|
def draw(self, surface: pygame.Surface):
|
114
|
-
|
300
|
+
"""
|
301
|
+
Draw the camera view onto the provided surface with proper scaling.
|
302
|
+
|
303
|
+
Args:
|
304
|
+
surface (pygame.Surface): Surface to draw the camera view onto.
|
305
|
+
"""
|
115
306
|
if self.zoom_factor == 1:
|
116
307
|
surface.blit(self.surface, (0, 0), special_flags=self.blit_special_flags)
|
308
|
+
# surface.blit(self.surface, (0, 0))
|
117
309
|
return
|
118
|
-
|
119
|
-
surface
|
120
|
-
|
121
|
-
|
122
|
-
special_flags=self.blit_special_flags,
|
123
|
-
)
|
310
|
+
|
311
|
+
# Scale the surface to match the resolution
|
312
|
+
scaled_surface = pygame.transform.scale(self.surface, self.target_size)
|
313
|
+
surface.blit(scaled_surface, (0, 0), special_flags=self.blit_special_flags)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import batFramework as bf
|
2
|
+
from .stateMachine import State
|
3
|
+
from .animatedSprite import AnimatedSprite
|
4
|
+
from .dynamicEntity import DynamicEntity
|
5
|
+
|
6
|
+
class Character(AnimatedSprite,DynamicEntity):
|
7
|
+
def __init__(self) -> None:
|
8
|
+
super().__init__()
|
9
|
+
self.state_machine = bf.StateMachine(self)
|
10
|
+
self.do_setup_animations()
|
11
|
+
self.do_setup_states()
|
12
|
+
|
13
|
+
def set_state(self,state_name:str):
|
14
|
+
self.state_machine.set_state(state_name)
|
15
|
+
|
16
|
+
def get_current_state(self)->State:
|
17
|
+
return self.state_machine.get_current_state()
|
18
|
+
|
19
|
+
def update(self, dt: float) -> None:
|
20
|
+
self.state_machine.update(dt)
|
21
|
+
super().update(dt)
|
22
|
+
|
23
|
+
def do_setup_states(self):
|
24
|
+
pass
|
25
|
+
|
26
|
+
def do_setup_animations(self):
|
27
|
+
pass
|
batFramework/constants.py
CHANGED
@@ -1,75 +1,37 @@
|
|
1
1
|
import pygame
|
2
|
-
from enum import Enum
|
3
2
|
|
4
3
|
|
5
4
|
class Constants:
|
6
|
-
SCREEN = None
|
7
|
-
RESOLUTION: tuple[int, int] = (1280,720)
|
5
|
+
SCREEN: pygame.Surface = None
|
6
|
+
RESOLUTION: tuple[int, int] = (1280, 720)
|
8
7
|
VSYNC = 0
|
9
8
|
FLAGS: int = pygame.SCALED | pygame.RESIZABLE
|
10
9
|
FPS: int = 60
|
11
|
-
RESOURCE_PATH = "."
|
12
|
-
|
13
|
-
@staticmethod
|
14
|
-
def init_screen(resolution:tuple[int,int],flags:int= 0, vsync:int= 0):
|
15
|
-
Constants.RESOLUTION = resolution
|
16
|
-
Constants.FLAGS = flags
|
17
|
-
Constants.VSYNC = vsync
|
18
|
-
Constants.SCREEN = pygame.display.set_mode(Constants.RESOLUTION, Constants.FLAGS,vsync=Constants.VSYNC)
|
19
|
-
print(f"Window : {resolution[0]}x{resolution[1]}px | flags:{flags.bit_count()}, vsync:{pygame.display.is_vsync()}")
|
20
10
|
MUSIC_END_EVENT = pygame.event.custom_type()
|
21
11
|
|
22
|
-
|
23
|
-
|
12
|
+
DEFAULT_CURSOR = pygame.cursors.Cursor(pygame.SYSTEM_CURSOR_ARROW)
|
13
|
+
DEFAULT_HOVER_CURSOR = pygame.cursors.Cursor(pygame.SYSTEM_CURSOR_ARROW)
|
14
|
+
DEFAULT_CLICK_CURSOR = pygame.cursors.Cursor(pygame.SYSTEM_CURSOR_ARROW)
|
24
15
|
|
25
|
-
|
26
|
-
# ---------------------
|
16
|
+
BF_INITIALIZED: bool = False
|
27
17
|
|
28
18
|
@staticmethod
|
29
|
-
def set_resolution(resolution
|
19
|
+
def set_resolution(resolution: tuple[int, int]):
|
30
20
|
Constants.RESOLUTION = resolution
|
31
21
|
|
32
22
|
@staticmethod
|
33
|
-
def
|
34
|
-
|
35
|
-
Constants.RESOURCE_PATH = path
|
23
|
+
def set_default_cursor(cursor: pygame.Cursor):
|
24
|
+
Constants.DEFAULT_CURSOR = cursor
|
36
25
|
|
37
26
|
@staticmethod
|
38
|
-
def
|
39
|
-
Constants.
|
40
|
-
print("FPS limit to : ", value)
|
27
|
+
def set_default_hover_cursor(cursor: pygame.Cursor):
|
28
|
+
Constants.DEFAULT_HOVER_CURSOR = cursor
|
41
29
|
|
42
30
|
@staticmethod
|
43
|
-
def
|
44
|
-
Constants.
|
45
|
-
print("GUI_SCALE to : ", value)
|
31
|
+
def set_default_click_cursor(cursor: pygame.Cursor):
|
32
|
+
Constants.DEFAULT_CLICK_CURSOR = cursor
|
46
33
|
|
47
34
|
@staticmethod
|
48
|
-
def
|
49
|
-
Constants.
|
50
|
-
|
51
|
-
class Colors:
|
52
|
-
LIGHT_CYAN = (179, 229, 252)
|
53
|
-
WASHED_BLUE = (52, 73, 94)
|
54
|
-
RIVER_BLUE = (52, 152, 219)
|
55
|
-
DARK_INDIGO = (40, 53, 147)
|
56
|
-
LIGHT_BLUE = (3, 169, 244)
|
57
|
-
DEEP_BLUE = (41, 121, 255)
|
58
|
-
DARK_BLUE = (44, 62, 80)
|
59
|
-
GREEN = (67, 160, 71)
|
60
|
-
DARK_GREEN = (39, 174, 96)
|
61
|
-
BROWN = (109, 76, 65)
|
62
|
-
DARK_RED = (192, 57, 43)
|
63
|
-
ORANGE = (251, 140, 0)
|
64
|
-
CLOUD_WHITE = (236, 240, 241)
|
65
|
-
SILVER = (189, 195, 199)
|
66
|
-
DARK_GRAY = (66, 66, 66)
|
67
|
-
|
68
|
-
DARK_GB = (27, 42, 9)
|
69
|
-
SHADE_GB = (14, 69, 11)
|
70
|
-
BASE_GB = (73, 107, 34)
|
71
|
-
LIGHT_GB = (154, 158, 63)
|
72
|
-
|
73
|
-
class Axis(Enum):
|
74
|
-
HORIZONTAL = 1
|
75
|
-
VERTICAL = 2
|
35
|
+
def set_fps_limit(value: int):
|
36
|
+
Constants.FPS = value
|
37
|
+
print("FPS limit to : ", value)
|
batFramework/cutscene.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
import batFramework as bf
|
2
|
+
from typing import TYPE_CHECKING
|
2
3
|
|
4
|
+
class CutsceneBlock: ...
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from .cutsceneBlocks import CutsceneBlock
|
6
8
|
|
7
9
|
|
8
|
-
class Cutscene:
|
9
|
-
...
|
10
|
+
class Cutscene: ...
|
10
11
|
|
11
12
|
|
12
13
|
class CutsceneManager(metaclass=bf.Singleton):
|
13
|
-
def __init__(self
|
14
|
+
def __init__(self) -> None:
|
14
15
|
self.current_cutscene: Cutscene = None
|
15
|
-
self.cutscenes
|
16
|
-
self.manager: bf.Manager =
|
16
|
+
self.cutscenes: list[bf.Cutscene] = []
|
17
|
+
self.manager: bf.Manager = None
|
18
|
+
|
19
|
+
def set_manager(self, manager):
|
20
|
+
self.manager = manager
|
17
21
|
|
18
22
|
def get_flag(self, flag):
|
19
23
|
return None
|
@@ -22,11 +26,11 @@ class CutsceneManager(metaclass=bf.Singleton):
|
|
22
26
|
if self.current_cutscene:
|
23
27
|
self.current_cutscene.process_event(event)
|
24
28
|
|
25
|
-
def queue(self
|
29
|
+
def queue(self, *cutscenes):
|
26
30
|
self.cutscenes.extend(cutscenes)
|
27
31
|
if self.current_cutscene is None:
|
28
32
|
self.play(self.cutscenes.pop(0))
|
29
|
-
|
33
|
+
|
30
34
|
def play(self, cutscene: Cutscene):
|
31
35
|
if self.current_cutscene is None:
|
32
36
|
self.current_cutscene = cutscene
|
@@ -35,25 +39,33 @@ class CutsceneManager(metaclass=bf.Singleton):
|
|
35
39
|
self.current_cutscene.play()
|
36
40
|
self.manager.set_sharedVar("in_cutscene", True)
|
37
41
|
|
42
|
+
def enable_player_control(self) -> None:
|
43
|
+
self.manager.set_sharedVar("player_has_control", True)
|
44
|
+
|
45
|
+
def disable_player_control(self) -> None:
|
46
|
+
self.manager.set_sharedVar("player_has_control", False)
|
47
|
+
|
38
48
|
def update(self, dt):
|
39
49
|
if not self.current_cutscene is None:
|
40
50
|
self.current_cutscene.update(dt)
|
41
51
|
# print("cutscene manager update")
|
42
52
|
if self.current_cutscene.has_ended():
|
43
53
|
self.current_cutscene.on_exit()
|
44
|
-
self.current_cutscene =None
|
54
|
+
self.current_cutscene = None
|
45
55
|
if self.cutscenes:
|
46
56
|
self.play(self.cutscenes.pop(0))
|
47
57
|
else:
|
48
58
|
self.current_cutscene = None
|
49
59
|
self.manager.set_sharedVar("in_cutscene", False)
|
50
60
|
|
61
|
+
|
51
62
|
class Cutscene:
|
52
|
-
def __init__(self
|
53
|
-
self.cutscene_blocks: list[CutsceneBlock] =
|
63
|
+
def __init__(self) -> None:
|
64
|
+
self.cutscene_blocks : list[CutsceneBlock] = []
|
54
65
|
self.block_index = 0
|
55
|
-
self.end_blocks
|
66
|
+
self.end_blocks: list[CutsceneBlock] = []
|
56
67
|
self.ended = False
|
68
|
+
|
57
69
|
def on_enter(self):
|
58
70
|
pass
|
59
71
|
|
@@ -63,23 +75,26 @@ class Cutscene:
|
|
63
75
|
def init_blocks(self):
|
64
76
|
pass
|
65
77
|
|
66
|
-
def
|
67
|
-
|
68
|
-
self.end_blocks.append(block)
|
78
|
+
def add_blocks(self, *blocks: CutsceneBlock):
|
79
|
+
self.cutscene_blocks.extend(blocks)
|
69
80
|
|
70
|
-
def
|
71
|
-
|
81
|
+
def add_end_blocks(self, *blocks: CutsceneBlock):
|
82
|
+
_ = [block.set_parent_cutscene(self) for block in blocks]
|
83
|
+
self.end_blocks.extend(blocks)
|
84
|
+
|
85
|
+
def get_scene_at(self, index):
|
86
|
+
return bf.CutsceneManager().manager.scenes[index]
|
72
87
|
|
73
88
|
def get_current_scene(self):
|
74
89
|
return bf.CutsceneManager().manager.get_current_scene()
|
75
|
-
|
76
|
-
def set_scene(self,name,index=0):
|
77
|
-
return bf.CutsceneManager().manager.set_scene(name,index)
|
78
90
|
|
79
|
-
def
|
91
|
+
def set_scene(self, name, index=0):
|
92
|
+
return bf.CutsceneManager().manager.set_scene(name, index)
|
93
|
+
|
94
|
+
def get_scene(self, name):
|
80
95
|
return bf.CutsceneManager().manager.get_scene(name)
|
81
|
-
|
82
|
-
def add_block(self, *blocks:
|
96
|
+
|
97
|
+
def add_block(self, *blocks: CutsceneBlock):
|
83
98
|
for block in blocks:
|
84
99
|
block.set_parent_cutscene(self)
|
85
100
|
self.cutscene_blocks.append(block)
|
@@ -98,7 +113,6 @@ class Cutscene:
|
|
98
113
|
def update(self, dt):
|
99
114
|
if self.ended:
|
100
115
|
return
|
101
|
-
# print("cutscene update",self.cutscene_blocks[self.block_index])
|
102
116
|
self.cutscene_blocks[self.block_index].update(dt)
|
103
117
|
if self.cutscene_blocks[self.block_index].has_ended():
|
104
118
|
self.block_index += 1
|
@@ -111,9 +125,5 @@ class Cutscene:
|
|
111
125
|
self.end_blocks = []
|
112
126
|
self.cutscene_blocks[self.block_index].start()
|
113
127
|
|
114
|
-
# print("NEXT BLOCK")
|
115
|
-
|
116
128
|
def has_ended(self):
|
117
129
|
return self.ended
|
118
|
-
|
119
|
-
|