batframework 1.0.8a7__py3-none-any.whl → 1.0.8a8__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.
Files changed (70) hide show
  1. batFramework/__init__.py +51 -68
  2. batFramework/action.py +99 -126
  3. batFramework/actionContainer.py +9 -53
  4. batFramework/animatedSprite.py +82 -141
  5. batFramework/audioManager.py +26 -69
  6. batFramework/camera.py +69 -259
  7. batFramework/constants.py +54 -16
  8. batFramework/cutscene.py +29 -39
  9. batFramework/cutsceneBlocks.py +43 -36
  10. batFramework/debugger.py +48 -0
  11. batFramework/dynamicEntity.py +9 -18
  12. batFramework/easing.py +71 -0
  13. batFramework/entity.py +97 -48
  14. batFramework/gui/__init__.py +2 -10
  15. batFramework/gui/button.py +78 -9
  16. batFramework/gui/constraints.py +204 -0
  17. batFramework/gui/container.py +32 -174
  18. batFramework/gui/debugger.py +43 -131
  19. batFramework/gui/frame.py +19 -0
  20. batFramework/gui/image.py +20 -56
  21. batFramework/gui/indicator.py +21 -38
  22. batFramework/gui/interactiveWidget.py +13 -192
  23. batFramework/gui/label.py +74 -309
  24. batFramework/gui/layout.py +63 -231
  25. batFramework/gui/root.py +38 -134
  26. batFramework/gui/shape.py +57 -237
  27. batFramework/gui/toggle.py +51 -101
  28. batFramework/gui/widget.py +250 -358
  29. batFramework/manager.py +19 -52
  30. batFramework/particles.py +77 -0
  31. batFramework/scene.py +123 -281
  32. batFramework/sceneManager.py +116 -178
  33. batFramework/stateMachine.py +8 -11
  34. batFramework/time.py +58 -145
  35. batFramework/transition.py +124 -195
  36. batFramework/transitionManager.py +0 -0
  37. batFramework/triggerZone.py +1 -1
  38. batFramework/utils.py +147 -112
  39. batframework-1.0.8a8.dist-info/METADATA +53 -0
  40. batframework-1.0.8a8.dist-info/RECORD +42 -0
  41. {batframework-1.0.8a7.dist-info → batframework-1.0.8a8.dist-info}/WHEEL +1 -1
  42. batFramework/character.py +0 -27
  43. batFramework/easingController.py +0 -58
  44. batFramework/enums.py +0 -113
  45. batFramework/fontManager.py +0 -65
  46. batFramework/gui/clickableWidget.py +0 -220
  47. batFramework/gui/constraints/__init__.py +0 -1
  48. batFramework/gui/constraints/constraints.py +0 -815
  49. batFramework/gui/dialogueBox.py +0 -99
  50. batFramework/gui/draggableWidget.py +0 -40
  51. batFramework/gui/meter.py +0 -74
  52. batFramework/gui/radioButton.py +0 -84
  53. batFramework/gui/slider.py +0 -240
  54. batFramework/gui/style.py +0 -10
  55. batFramework/gui/styleManager.py +0 -48
  56. batFramework/gui/textInput.py +0 -247
  57. batFramework/object.py +0 -123
  58. batFramework/particle.py +0 -115
  59. batFramework/renderGroup.py +0 -67
  60. batFramework/resourceManager.py +0 -100
  61. batFramework/scrollingSprite.py +0 -114
  62. batFramework/sprite.py +0 -51
  63. batFramework/templates/__init__.py +0 -2
  64. batFramework/templates/character.py +0 -44
  65. batFramework/templates/states.py +0 -166
  66. batFramework/tileset.py +0 -46
  67. batframework-1.0.8a7.dist-info/LICENCE +0 -21
  68. batframework-1.0.8a7.dist-info/METADATA +0 -43
  69. batframework-1.0.8a7.dist-info/RECORD +0 -62
  70. {batframework-1.0.8a7.dist-info → batframework-1.0.8a8.dist-info}/top_level.txt +0 -0
batFramework/camera.py CHANGED
@@ -1,313 +1,123 @@
1
+ import batFramework as bf
1
2
  import pygame
2
3
  from pygame.math import Vector2
3
- import batFramework as bf
4
- from typing import Self
5
- import math
6
4
 
7
5
 
8
6
  class Camera:
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)
7
+ def __init__(self, flags=0) -> None:
8
+ self.rect = pygame.FRect(0, 0, *bf.const.RESOLUTION)
9
+ self.flags: int = flags
10
+ # self.blit_special_flags : int =pygame.BLEND_PREMULTIPLIED if (flags & pygame.SRCALPHA) else 0
29
11
  self.blit_special_flags: int = pygame.BLEND_ALPHA_SDL2
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
-
35
- self.follow_point_func = None
36
- self.damping = float("inf")
37
- self.dead_zone_radius = 10
38
-
12
+ self._clear_color : pygame.Color = pygame.Color(0, 0, 0, 0)
39
13
  self.zoom_factor = 1
14
+ self.cached_surfaces: dict[float, pygame.Surface] = {}
15
+ self.surface: pygame.Surface = pygame.Surface((0,0))
16
+ self.follow_point_func = None
40
17
  self.max_zoom = 2
41
18
  self.min_zoom = 0.1
42
19
  self.zoom(1)
43
20
 
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
- """
21
+ def set_clear_color(self, color: pygame.Color|tuple):
22
+ if not isinstance(color,pygame.Color):
23
+ color = pygame.Color(color)
54
24
  self._clear_color = color
55
- return self
56
25
 
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
- """
26
+ def set_max_zoom(self,value:float):
67
27
  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.
76
28
 
77
- Returns:
78
- Camera: Returns the Camera object.
79
- """
29
+ def set_min_zoom(self,value:float):
80
30
  self.min_zoom = value
81
- return self
82
31
 
83
- def clear(self) -> None:
32
+ def clear(self):
84
33
  """
85
- Clear the camera surface with the set clear color.
34
+ Clear the camera surface with the set clear color
35
+ (default is tranparent)
86
36
  """
87
37
  self.surface.fill(self._clear_color)
88
38
 
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
- """
39
+ def get_center(self):
96
40
  return self.rect.center
97
41
 
98
- def get_position(self) -> tuple[float, float]:
99
- """
100
- Get the center of the camera's view.
42
+
101
43
 
102
- Returns:
103
- tuple[float,float]: Returns the center coordinates.
44
+ def move(self, x, y):
104
45
  """
105
- return self.rect.topleft
106
-
107
- def move_by(self, x: float | int, y: float | int) -> Self:
46
+ Moves the camera rect by the given coordinates (+=)
108
47
  """
109
- Moves the camera rect by the given coordinates.
110
-
111
- Args:
112
- x: X-coordinate to move.
113
- y: Y-coordinate to move.
48
+ self.rect.topleft += Vector2(x, y)
114
49
 
115
- Returns:
116
- Camera: Returns the Camera object.
50
+ def set_position(self, x, y):
117
51
  """
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.
52
+ Set the camera rect topleft position
131
53
  """
132
54
  self.rect.topleft = (x, y)
133
55
 
134
- return self
135
-
136
- def set_center(self, x, y) -> Self:
56
+ def set_center(self, x, y):
137
57
  """
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.
58
+ Set the camera rect center position
146
59
  """
147
60
  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
165
61
 
166
- def zoom_by(self, amount: float) -> Self:
62
+ def set_follow_dynamic_point(self, func):
167
63
  """
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.
175
- """
176
- self.zoom(max(self.min_zoom, min(self.max_zoom, self.zoom_factor + amount)))
177
- return self
178
-
179
- def zoom(self, factor: float) -> Self:
64
+ Set the following function (returns tuple x y)
65
+ (camera will center its position to the center of the given coordinates)
180
66
  """
181
- Zooms the camera to the given factor.
67
+ self.follow_point_func = func
182
68
 
183
- Args:
184
- factor: Factor to set for zooming.
69
+ def zoom_by(self, amount:float):
70
+ self.zoom(self.zoom_factor + amount)
185
71
 
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)
72
+ def zoom(self, factor):
73
+ if factor <self.min_zoom:
74
+ return
75
+ if factor > self.max_zoom:
76
+ return
77
+ factor = round(factor,2)
196
78
  self.zoom_factor = 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)
79
+ if factor not in self.cached_surfaces:
80
+ # if factor != 1 : print("creating new surface in cache : ",tuple(i * factor for i in const.RESOLUTION), self.flags)
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]
199
89
  self.rect = self.surface.get_frect(center=self.rect.center)
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
90
+ # if factor != 1 : print(self.cached_surfaces)
224
91
 
225
92
  def intersects(self, rect: pygame.Rect | pygame.FRect) -> bool:
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]
251
- )
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.
261
-
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.
272
-
273
- Args:
274
- point (tuple[float,float] | tuple[int,int]): Point to screen_to_world.
275
- Returns:
276
- tuple: Converted world coordinates.
277
- """
278
93
  return (
279
- point[0] / self.zoom_factor + self.rect.x,
280
- point[1] / self.zoom_factor + self.rect.y,
94
+ self.rect.x < rect.right
95
+ and self.rect.right > rect.x
96
+ and self.rect.y < rect.bottom
97
+ and self.rect.bottom > rect.y
281
98
  )
282
99
 
283
- def update(self, dt):
284
- if not self.follow_point_func or not (math.isfinite(dt) and dt > 0):
285
- return
286
100
 
287
- target = Vector2(self.follow_point_func())
288
- self.vector_center.update(self.rect.center)
101
+ def transpose(self, rect: pygame.Rect | pygame.FRect) -> pygame.Rect | pygame.FRect:
102
+ x, y = round(rect.x - self.rect.left), round(rect.y - self.rect.top)
103
+ return pygame.Rect(x, y, *rect.size)
289
104
 
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
105
+ def convert_screen_to_world(self, x, y):
106
+ return x / self.zoom_factor + self.rect.x, y / self.zoom_factor + self.rect.y
296
107
 
297
- self.rect.center = self.vector_center
108
+ def update(self, dt):
109
+ if self.follow_point_func:
110
+ target = self.follow_point_func()
111
+ self.rect.center = Vector2(self.rect.center).lerp(target, ((dt * 60) * 0.1))
298
112
 
299
113
  def draw(self, surface: pygame.Surface):
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
- """
114
+ # pygame.draw.circle(surface,bf.color.ORANGE,self.surface.get_rect().center,4)
306
115
  if self.zoom_factor == 1:
307
116
  surface.blit(self.surface, (0, 0), special_flags=self.blit_special_flags)
308
- # surface.blit(self.surface, (0, 0))
309
117
  return
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)
118
+ # print("From",self.surface,"Target RESOLUTION",const.RESOLUTION,"Destination",surface)
119
+ surface.blit(
120
+ pygame.transform.scale(self.surface, bf.const.RESOLUTION),
121
+ (0, 0),
122
+ special_flags=self.blit_special_flags,
123
+ )
batFramework/constants.py CHANGED
@@ -1,37 +1,75 @@
1
1
  import pygame
2
+ from enum import Enum
2
3
 
3
4
 
4
5
  class Constants:
5
- SCREEN: pygame.Surface = None
6
- RESOLUTION: tuple[int, int] = (1280, 720)
6
+ SCREEN = None
7
+ RESOLUTION: tuple[int, int] = (1280,720)
7
8
  VSYNC = 0
8
9
  FLAGS: int = pygame.SCALED | pygame.RESIZABLE
9
10
  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()}")
10
20
  MUSIC_END_EVENT = pygame.event.custom_type()
11
21
 
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)
22
+ # ------------GUI SPECIFIC
23
+ DEFAULT_TEXT_SIZE: int = 8
15
24
 
16
- BF_INITIALIZED: bool = False
25
+ GUI_SCALE: int = 1
26
+ # ---------------------
17
27
 
18
28
  @staticmethod
19
- def set_resolution(resolution: tuple[int, int]):
29
+ def set_resolution(resolution : tuple[int,int]):
20
30
  Constants.RESOLUTION = resolution
21
31
 
22
32
  @staticmethod
23
- def set_default_cursor(cursor: pygame.Cursor):
24
- Constants.DEFAULT_CURSOR = cursor
33
+ def set_resource_path(path: str):
34
+ print("set resource path :", path)
35
+ Constants.RESOURCE_PATH = path
25
36
 
26
37
  @staticmethod
27
- def set_default_hover_cursor(cursor: pygame.Cursor):
28
- Constants.DEFAULT_HOVER_CURSOR = cursor
38
+ def set_fps_limit(value: int):
39
+ Constants.FPS = value
40
+ print("FPS limit to : ", value)
29
41
 
30
42
  @staticmethod
31
- def set_default_click_cursor(cursor: pygame.Cursor):
32
- Constants.DEFAULT_CLICK_CURSOR = cursor
43
+ def set_gui_scale(value: int):
44
+ Constants.GUI_SCALE = value
45
+ print("GUI_SCALE to : ", value)
33
46
 
34
47
  @staticmethod
35
- def set_fps_limit(value: int):
36
- Constants.FPS = value
37
- print("FPS limit to : ", value)
48
+ def set_default_text_size(size:int):
49
+ Constants.DEFAULT_TEXT_SIZE = size
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
batFramework/cutscene.py CHANGED
@@ -1,23 +1,19 @@
1
1
  import batFramework as bf
2
- from typing import TYPE_CHECKING
3
2
 
4
- class CutsceneBlock: ...
5
3
 
6
- if TYPE_CHECKING:
7
- from .cutsceneBlocks import CutsceneBlock
4
+ class CutsceneBlock:
5
+ ...
8
6
 
9
7
 
10
- class Cutscene: ...
8
+ class Cutscene:
9
+ ...
11
10
 
12
11
 
13
12
  class CutsceneManager(metaclass=bf.Singleton):
14
- def __init__(self) -> None:
13
+ def __init__(self, manager) -> None:
15
14
  self.current_cutscene: Cutscene = None
16
- self.cutscenes: list[bf.Cutscene] = []
17
- self.manager: bf.Manager = None
18
-
19
- def set_manager(self, manager):
20
- self.manager = manager
15
+ self.cutscenes : list[bf.Cutscene] = []
16
+ self.manager: bf.Manager = manager
21
17
 
22
18
  def get_flag(self, flag):
23
19
  return None
@@ -26,11 +22,11 @@ class CutsceneManager(metaclass=bf.Singleton):
26
22
  if self.current_cutscene:
27
23
  self.current_cutscene.process_event(event)
28
24
 
29
- def queue(self, *cutscenes):
25
+ def queue(self,*cutscenes):
30
26
  self.cutscenes.extend(cutscenes)
31
27
  if self.current_cutscene is None:
32
28
  self.play(self.cutscenes.pop(0))
33
-
29
+
34
30
  def play(self, cutscene: Cutscene):
35
31
  if self.current_cutscene is None:
36
32
  self.current_cutscene = cutscene
@@ -39,33 +35,25 @@ class CutsceneManager(metaclass=bf.Singleton):
39
35
  self.current_cutscene.play()
40
36
  self.manager.set_sharedVar("in_cutscene", True)
41
37
 
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
-
48
38
  def update(self, dt):
49
39
  if not self.current_cutscene is None:
50
40
  self.current_cutscene.update(dt)
51
41
  # print("cutscene manager update")
52
42
  if self.current_cutscene.has_ended():
53
43
  self.current_cutscene.on_exit()
54
- self.current_cutscene = None
44
+ self.current_cutscene =None
55
45
  if self.cutscenes:
56
46
  self.play(self.cutscenes.pop(0))
57
47
  else:
58
48
  self.current_cutscene = None
59
49
  self.manager.set_sharedVar("in_cutscene", False)
60
50
 
61
-
62
51
  class Cutscene:
63
- def __init__(self) -> None:
64
- self.cutscene_blocks : list[CutsceneBlock] = []
52
+ def __init__(self,*blocks) -> None:
53
+ self.cutscene_blocks: list[CutsceneBlock] = list(blocks)
65
54
  self.block_index = 0
66
- self.end_blocks: list[CutsceneBlock] = []
55
+ self.end_blocks : list[CutsceneBlock] = []
67
56
  self.ended = False
68
-
69
57
  def on_enter(self):
70
58
  pass
71
59
 
@@ -75,26 +63,23 @@ class Cutscene:
75
63
  def init_blocks(self):
76
64
  pass
77
65
 
78
- def add_blocks(self, *blocks: CutsceneBlock):
79
- self.cutscene_blocks.extend(blocks)
66
+ def add_end_block(self,block):
67
+ block.set_parent_cutscene(self)
68
+ self.end_blocks.append(block)
80
69
 
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]
70
+ def get_scene_at(self,index):
71
+ return bf.CutsceneManager().manager._scenes[index]
87
72
 
88
73
  def get_current_scene(self):
89
74
  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)
90
78
 
91
- def set_scene(self, name, index=0):
92
- return bf.CutsceneManager().manager.set_scene(name, index)
93
-
94
- def get_scene(self, name):
79
+ def get_scene(self,name):
95
80
  return bf.CutsceneManager().manager.get_scene(name)
96
-
97
- def add_block(self, *blocks: CutsceneBlock):
81
+
82
+ def add_block(self, *blocks: list[CutsceneBlock]):
98
83
  for block in blocks:
99
84
  block.set_parent_cutscene(self)
100
85
  self.cutscene_blocks.append(block)
@@ -113,6 +98,7 @@ class Cutscene:
113
98
  def update(self, dt):
114
99
  if self.ended:
115
100
  return
101
+ # print("cutscene update",self.cutscene_blocks[self.block_index])
116
102
  self.cutscene_blocks[self.block_index].update(dt)
117
103
  if self.cutscene_blocks[self.block_index].has_ended():
118
104
  self.block_index += 1
@@ -125,5 +111,9 @@ class Cutscene:
125
111
  self.end_blocks = []
126
112
  self.cutscene_blocks[self.block_index].start()
127
113
 
114
+ # print("NEXT BLOCK")
115
+
128
116
  def has_ended(self):
129
117
  return self.ended
118
+
119
+