batframework 1.0.7__py3-none-any.whl → 1.0.8a2__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 (51) hide show
  1. batFramework/__init__.py +47 -41
  2. batFramework/action.py +20 -42
  3. batFramework/actionContainer.py +4 -43
  4. batFramework/animatedSprite.py +65 -98
  5. batFramework/audioManager.py +25 -39
  6. batFramework/camera.py +56 -226
  7. batFramework/constants.py +48 -32
  8. batFramework/cutscene.py +24 -32
  9. batFramework/cutsceneBlocks.py +33 -30
  10. batFramework/debugger.py +48 -0
  11. batFramework/dynamicEntity.py +7 -8
  12. batFramework/easing.py +23 -28
  13. batFramework/entity.py +52 -89
  14. batFramework/gui/__init__.py +1 -3
  15. batFramework/gui/button.py +58 -124
  16. batFramework/gui/constraints.py +90 -163
  17. batFramework/gui/container.py +18 -29
  18. batFramework/gui/debugger.py +42 -106
  19. batFramework/gui/frame.py +9 -15
  20. batFramework/gui/image.py +17 -36
  21. batFramework/gui/indicator.py +14 -20
  22. batFramework/gui/interactiveWidget.py +12 -63
  23. batFramework/gui/label.py +50 -113
  24. batFramework/gui/layout.py +51 -66
  25. batFramework/gui/root.py +29 -70
  26. batFramework/gui/shape.py +41 -34
  27. batFramework/gui/toggle.py +29 -37
  28. batFramework/gui/widget.py +131 -174
  29. batFramework/manager.py +14 -21
  30. batFramework/particles.py +20 -41
  31. batFramework/scene.py +72 -173
  32. batFramework/sceneManager.py +80 -40
  33. batFramework/stateMachine.py +0 -1
  34. batFramework/time.py +51 -62
  35. batFramework/transition.py +154 -0
  36. batFramework/utils.py +150 -3
  37. batframework-1.0.8a2.dist-info/METADATA +58 -0
  38. batframework-1.0.8a2.dist-info/RECORD +42 -0
  39. {batframework-1.0.7.dist-info → batframework-1.0.8a2.dist-info}/WHEEL +1 -1
  40. batFramework/enums.py +0 -14
  41. batFramework/fontManager.py +0 -57
  42. batFramework/gui/dialogueBox.py +0 -70
  43. batFramework/gui/slider.py +0 -5
  44. batFramework/gui/textInput.py +0 -88
  45. batFramework/resourceManager.py +0 -72
  46. batFramework/sprite.py +0 -33
  47. batFramework/tileset.py +0 -64
  48. batframework-1.0.7.dist-info/LICENCE +0 -21
  49. batframework-1.0.7.dist-info/METADATA +0 -55
  50. batframework-1.0.7.dist-info/RECORD +0 -50
  51. {batframework-1.0.7.dist-info → batframework-1.0.8a2.dist-info}/top_level.txt +0 -0
batFramework/camera.py CHANGED
@@ -1,293 +1,123 @@
1
+ import batFramework as bf
1
2
  import pygame
2
3
  from pygame.math import Vector2
3
- import math
4
- import batFramework as bf
5
4
 
6
5
 
7
6
  class Camera:
8
-
9
- def __init__(self, flags=0, size: tuple[int,int] | None = None,convert_alpha:bool=False) -> None:
10
- """
11
- Initialize the Camera object.
12
-
13
- Args:
14
- flags (int): Flags for camera initialization.
15
- size (tuple): Optional size for camera (defaults to window size)
16
- convert_alpha (bool): Convert surface to support alpha values
17
- """
18
- size = size if size else bf.const.RESOLUTION
19
- self.should_convert_alpha :bool = convert_alpha
20
- self.rect = pygame.FRect(0, 0, *size)
21
- self.vector_center = Vector2(0,0)
22
-
23
- self.surface: pygame.Surface = pygame.Surface((0, 0)) #tmp dummy
24
- 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
25
11
  self.blit_special_flags: int = pygame.BLEND_ALPHA_SDL2
26
-
27
- self._clear_color: pygame.Color = pygame.Color(0, 0, 0, 0 if convert_alpha else 255)
28
-
12
+ self._clear_color : pygame.Color = pygame.Color(0, 0, 0, 0)
13
+ self.zoom_factor = 1
29
14
  self.cached_surfaces: dict[float, pygame.Surface] = {}
30
-
15
+ self.surface: pygame.Surface = pygame.Surface((0,0))
31
16
  self.follow_point_func = None
32
- self.follow_speed :float= 0.1
33
-
34
- self.zoom_factor = 1
35
17
  self.max_zoom = 2
36
18
  self.min_zoom = 0.1
37
19
  self.zoom(1)
38
20
 
39
- def set_clear_color(self, color: pygame.Color | tuple | str) -> "Camera":
40
- """
41
- Set the clear color for the camera surface.
42
-
43
- Args:
44
- color (pygame.Color | tuple): Color to set as the clear color.
45
-
46
- Returns:
47
- Camera: Returns the Camera object.
48
- """
49
- if not isinstance(color, pygame.Color):
21
+ def set_clear_color(self, color: pygame.Color|tuple):
22
+ if not isinstance(color,pygame.Color):
50
23
  color = pygame.Color(color)
51
24
  self._clear_color = color
52
- return self
53
-
54
- def set_max_zoom(self, value: float) -> "Camera":
55
- """
56
- Set the maximum zoom value for the camera.
57
-
58
- Args:
59
- value (float): Maximum zoom value.
60
25
 
61
- Returns:
62
- Camera: Returns the Camera object.
63
- """
26
+ def set_max_zoom(self,value:float):
64
27
  self.max_zoom = value
65
- return self
66
-
67
- def set_min_zoom(self, value: float) -> "Camera":
68
- """
69
- Set the minimum zoom value for the camera.
70
-
71
- Args:
72
- value (float): Minimum zoom value.
73
28
 
74
- Returns:
75
- Camera: Returns the Camera object.
76
- """
29
+ def set_min_zoom(self,value:float):
77
30
  self.min_zoom = value
78
- return self
79
31
 
80
- def clear(self) -> None:
32
+ def clear(self):
81
33
  """
82
- Clear the camera surface with the set clear color.
34
+ Clear the camera surface with the set clear color
35
+ (default is tranparent)
83
36
  """
84
37
  self.surface.fill(self._clear_color)
85
38
 
86
- def get_center(self) -> tuple[float,float]:
87
- """
88
- Get the center of the camera's view.
89
-
90
- Returns:
91
- tuple[float,float]: Returns the center coordinates.
92
- """
39
+ def get_center(self):
93
40
  return self.rect.center
94
41
 
95
- def get_position(self) -> tuple[float,float]:
96
- """
97
- Get the center of the camera's view.
42
+
98
43
 
99
- Returns:
100
- tuple[float,float]: Returns the center coordinates.
44
+ def move(self, x, y):
101
45
  """
102
- return self.rect.topleft
103
-
104
- def move_by(self, x : float|int, y:float|int) -> "Camera":
105
- """
106
- Moves the camera rect by the given coordinates.
107
-
108
- Args:
109
- x: X-coordinate to move.
110
- y: Y-coordinate to move.
111
-
112
- Returns:
113
- Camera: Returns the Camera object.
46
+ Moves the camera rect by the given coordinates (+=)
114
47
  """
115
- self.rect.move_ip(x, y)
116
- self.vector_center.update(self.rect.center)
117
- return self
48
+ self.rect.topleft += Vector2(x, y)
118
49
 
119
- def set_position(self, x, y) -> "Camera":
50
+ def set_position(self, x, y):
120
51
  """
121
- Set the camera rect top-left position.
122
-
123
- Args:
124
- x: X-coordinate to set.
125
- y: Y-coordinate to set.
126
-
127
- Returns:
128
- Camera: Returns the Camera object.
52
+ Set the camera rect topleft position
129
53
  """
130
54
  self.rect.topleft = (x, y)
131
- self.vector_center.update(self.rect.center)
132
-
133
- return self
134
55
 
135
- def set_center(self, x, y) -> "Camera":
56
+ def set_center(self, x, y):
136
57
  """
137
- Set the camera rect center position.
138
-
139
- Args:
140
- x: X-coordinate for the center.
141
- y: Y-coordinate for the center.
142
-
143
- Returns:
144
- Camera: Returns the Camera object.
58
+ Set the camera rect center position
145
59
  """
146
60
  self.rect.center = (x, y)
147
- self.vector_center.update(self.rect.center)
148
- return self
149
61
 
150
- def set_follow_point(self, func,follow_speed :float = 0.1) -> "Camera":
62
+ def set_follow_dynamic_point(self, func):
151
63
  """
152
- Set the following function (returns tuple x y).
153
- Camera will center its position to the center of the given coordinates.
154
-
155
- Args:
156
- func: Function returning coordinates to follow.
157
-
158
- Returns:
159
- Camera: Returns the Camera object.
64
+ Set the following function (returns tuple x y)
65
+ (camera will center its position to the center of the given coordinates)
160
66
  """
161
67
  self.follow_point_func = func
162
- self.follow_speed = follow_speed if func else 0.1
163
- return self
164
-
165
- def zoom_by(self, amount: float) -> "Camera":
166
- """
167
- Zooms the camera by the given amount.
168
68
 
169
- Args:
170
- amount (float): Amount to zoom.
171
-
172
- Returns:
173
- Camera: Returns the Camera object.
174
- """
69
+ def zoom_by(self, amount:float):
175
70
  self.zoom(self.zoom_factor + amount)
176
- return self
177
-
178
- def zoom(self, factor) -> "Camera":
179
- """
180
- Zooms the camera to the given factor.
181
-
182
- Args:
183
- factor: Factor to set for zooming.
184
71
 
185
- Returns:
186
- Camera: Returns the Camera object.
187
- """
188
- if factor < self.min_zoom or factor > self.max_zoom:
189
- return self
190
-
191
- 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)
192
78
  self.zoom_factor = factor
193
-
194
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)
195
81
  self.cached_surfaces[factor] = pygame.Surface(
196
82
  tuple(i / factor for i in bf.const.RESOLUTION), flags=self.flags
197
- )
198
- if self.should_convert_alpha :
199
- self.cached_surfaces[factor].convert_alpha()
200
- else:
201
- self.cached_surfaces[factor].convert()
202
- # self.cached_surfaces[factor].fill((self._clear_color))
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))
203
87
 
204
88
  self.surface = self.cached_surfaces[self.zoom_factor]
205
89
  self.rect = self.surface.get_frect(center=self.rect.center)
206
- self.clear()
207
- return self
90
+ # if factor != 1 : print(self.cached_surfaces)
208
91
 
209
92
  def intersects(self, rect: pygame.Rect | pygame.FRect) -> bool:
210
- """
211
- Check if the camera view intersects with the given rectangle.
93
+ return (
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
98
+ )
212
99
 
213
- Args:
214
- rect (pygame.Rect | pygame.FRect): Rectangle to check intersection with.
215
-
216
- Returns:
217
- bool: True if intersection occurs, False otherwise.
218
- """
219
- # return (
220
- # self.rect.x < rect.right
221
- # and self.rect.right > rect.x
222
- # and self.rect.y < rect.bottom
223
- # and self.rect.bottom > rect.y
224
- # )
225
- return self.rect.colliderect(rect)
226
100
 
227
101
  def transpose(self, rect: pygame.Rect | pygame.FRect) -> pygame.Rect | pygame.FRect:
228
- """
229
- Transpose the given rectangle coordinates relative to the camera.
230
-
231
- Args:
232
- rect (pygame.Rect | pygame.FRect): Rectangle to transpose.
233
-
234
- Returns:
235
- pygame.FRect: Transposed rectangle.
236
- """
237
- return pygame.FRect(rect.x - self.rect.left, rect.y - self.rect.top, *rect.size)
238
-
239
-
240
- def transpose_point(self, point: tuple[float,float] | tuple[int,int]) -> tuple[float,float]:
241
- """
242
- Transpose the given 2D point coordinates relative to the camera.
243
-
244
- Args:
245
- point (tuple[float,float] | tuple[int,int]): Point to transpose.
246
-
247
- Returns:
248
- tuple[float,float] : Transposed point.
249
- """
250
- return point[0]-self.rect.x,point[1]-self.rect.y
251
-
252
-
102
+ x, y = round(rect.x - self.rect.left), round(rect.y - self.rect.top)
103
+ return pygame.Rect(x, y, *rect.size)
253
104
 
254
105
  def convert_screen_to_world(self, x, y):
255
- """
256
- Convert screen coordinates to world coordinates based on camera settings.
257
-
258
- Args:
259
- x: X-coordinate in screen space.
260
- y: Y-coordinate in screen space.
261
-
262
- Returns:
263
- tuple: Converted world coordinates.
264
- """
265
106
  return x / self.zoom_factor + self.rect.x, y / self.zoom_factor + self.rect.y
266
107
 
267
108
  def update(self, dt):
268
- """
269
- Update the camera position based on the follow point function.
270
-
271
- Args:
272
- dt: Time delta for updating the camera position.
273
- """
274
109
  if self.follow_point_func:
275
- amount = ((dt * 60) * self.follow_speed)
276
110
  target = self.follow_point_func()
277
- self.set_center(*self.vector_center.lerp(target, amount))
111
+ self.rect.center = Vector2(self.rect.center).lerp(target, ((dt * 60) * 0.1))
278
112
 
279
113
  def draw(self, surface: pygame.Surface):
280
- """
281
- Draw the camera view onto the provided surface with proper scaling.
282
-
283
- Args:
284
- surface (pygame.Surface): Surface to draw the camera view onto.
285
- """
114
+ # pygame.draw.circle(surface,bf.color.ORANGE,self.surface.get_rect().center,4)
286
115
  if self.zoom_factor == 1:
287
116
  surface.blit(self.surface, (0, 0), special_flags=self.blit_special_flags)
288
- # surface.blit(self.surface, (0, 0))
289
117
  return
290
-
291
- # Scale the surface to match the resolution
292
- scaled_surface = pygame.transform.scale(self.surface, bf.const.RESOLUTION)
293
- 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,15 +1,52 @@
1
1
  import pygame
2
2
  from enum import Enum
3
- import sys, os
4
3
 
5
4
 
6
- if getattr(sys, "frozen", False):
7
- # If the application is run as a bundle, the PyInstaller bootloader
8
- # extends the sys module by a flag frozen=True and sets the app
9
- # path into variable _MEIPASS'.
10
- application_path = sys._MEIPASS
11
- else:
12
- application_path = os.getcwd()
5
+ class Constants:
6
+ SCREEN = None
7
+ RESOLUTION: tuple[int, int] = (1280,720)
8
+ VSYNC = 0
9
+ FLAGS: int = pygame.SCALED | pygame.RESIZABLE
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()}")
20
+ MUSIC_END_EVENT = pygame.event.custom_type()
21
+
22
+ # ------------GUI SPECIFIC
23
+ DEFAULT_TEXT_SIZE: int = 8
24
+
25
+ GUI_SCALE: int = 1
26
+ # ---------------------
27
+
28
+ @staticmethod
29
+ def set_resolution(resolution : tuple[int,int]):
30
+ Constants.RESOLUTION = resolution
31
+
32
+ @staticmethod
33
+ def set_resource_path(path: str):
34
+ print("set resource path :", path)
35
+ Constants.RESOURCE_PATH = path
36
+
37
+ @staticmethod
38
+ def set_fps_limit(value: int):
39
+ Constants.FPS = value
40
+ print("FPS limit to : ", value)
41
+
42
+ @staticmethod
43
+ def set_gui_scale(value: int):
44
+ Constants.GUI_SCALE = value
45
+ print("GUI_SCALE to : ", value)
46
+
47
+ @staticmethod
48
+ def set_default_text_size(size:int):
49
+ Constants.DEFAULT_TEXT_SIZE = size
13
50
 
14
51
  class Colors:
15
52
  LIGHT_CYAN = (179, 229, 252)
@@ -19,15 +56,11 @@ class Colors:
19
56
  LIGHT_BLUE = (3, 169, 244)
20
57
  DEEP_BLUE = (41, 121, 255)
21
58
  DARK_BLUE = (44, 62, 80)
22
-
23
59
  GREEN = (67, 160, 71)
24
60
  DARK_GREEN = (39, 174, 96)
25
-
26
61
  BROWN = (109, 76, 65)
27
62
  DARK_RED = (192, 57, 43)
28
-
29
63
  ORANGE = (251, 140, 0)
30
-
31
64
  CLOUD_WHITE = (236, 240, 241)
32
65
  SILVER = (189, 195, 199)
33
66
  DARK_GRAY = (66, 66, 66)
@@ -37,23 +70,6 @@ class Colors:
37
70
  BASE_GB = (73, 107, 34)
38
71
  LIGHT_GB = (154, 158, 63)
39
72
 
40
-
41
-
42
- class Constants:
43
- SCREEN = None
44
- RESOLUTION: tuple[int, int] = (1280, 720)
45
- VSYNC = 0
46
- FLAGS: int = pygame.SCALED | pygame.RESIZABLE
47
- FPS: int = 60
48
- MUSIC_END_EVENT = pygame.event.custom_type()
49
-
50
- BF_INITIALIZED : bool = False
51
- @staticmethod
52
- def set_resolution(resolution: tuple[int, int]):
53
- Constants.RESOLUTION = resolution
54
-
55
- @staticmethod
56
- def set_fps_limit(value: int):
57
- Constants.FPS = value
58
- print("FPS limit to : ", value)
59
-
73
+ class Axis(Enum):
74
+ HORIZONTAL = 1
75
+ VERTICAL = 2
batFramework/cutscene.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import batFramework as bf
2
2
 
3
+
3
4
  class CutsceneBlock:
4
5
  ...
5
6
 
@@ -9,13 +10,10 @@ class Cutscene:
9
10
 
10
11
 
11
12
  class CutsceneManager(metaclass=bf.Singleton):
12
- def __init__(self) -> None:
13
+ def __init__(self, manager) -> None:
13
14
  self.current_cutscene: Cutscene = None
14
- self.cutscenes: list[bf.Cutscene] = []
15
- self.manager = None
16
-
17
- def set_manager(self,manager):
18
- self.manager = manager
15
+ self.cutscenes : list[bf.Cutscene] = []
16
+ self.manager: bf.Manager = manager
19
17
 
20
18
  def get_flag(self, flag):
21
19
  return None
@@ -24,11 +22,11 @@ class CutsceneManager(metaclass=bf.Singleton):
24
22
  if self.current_cutscene:
25
23
  self.current_cutscene.process_event(event)
26
24
 
27
- def queue(self, *cutscenes):
25
+ def queue(self,*cutscenes):
28
26
  self.cutscenes.extend(cutscenes)
29
27
  if self.current_cutscene is None:
30
28
  self.play(self.cutscenes.pop(0))
31
-
29
+
32
30
  def play(self, cutscene: Cutscene):
33
31
  if self.current_cutscene is None:
34
32
  self.current_cutscene = cutscene
@@ -37,32 +35,25 @@ class CutsceneManager(metaclass=bf.Singleton):
37
35
  self.current_cutscene.play()
38
36
  self.manager.set_sharedVar("in_cutscene", True)
39
37
 
40
- def enable_player_control(self)->None:
41
- self.manager.set_sharedVar("player_has_control",True)
42
- def disable_player_control(self)->None:
43
- self.manager.set_sharedVar("player_has_control",False)
44
-
45
38
  def update(self, dt):
46
39
  if not self.current_cutscene is None:
47
40
  self.current_cutscene.update(dt)
48
41
  # print("cutscene manager update")
49
42
  if self.current_cutscene.has_ended():
50
43
  self.current_cutscene.on_exit()
51
- self.current_cutscene = None
44
+ self.current_cutscene =None
52
45
  if self.cutscenes:
53
46
  self.play(self.cutscenes.pop(0))
54
47
  else:
55
48
  self.current_cutscene = None
56
49
  self.manager.set_sharedVar("in_cutscene", False)
57
50
 
58
-
59
51
  class Cutscene:
60
- def __init__(self) -> None:
61
- self.cutscene_blocks = []
52
+ def __init__(self,*blocks) -> None:
53
+ self.cutscene_blocks: list[CutsceneBlock] = list(blocks)
62
54
  self.block_index = 0
63
- self.end_blocks: list[CutsceneBlock] = []
55
+ self.end_blocks : list[CutsceneBlock] = []
64
56
  self.ended = False
65
-
66
57
  def on_enter(self):
67
58
  pass
68
59
 
@@ -72,26 +63,23 @@ class Cutscene:
72
63
  def init_blocks(self):
73
64
  pass
74
65
 
75
- def add_blocks(self,*blocks:CutsceneBlock):
76
- self.cutscene_blocks.extend(blocks)
66
+ def add_end_block(self,block):
67
+ block.set_parent_cutscene(self)
68
+ self.end_blocks.append(block)
77
69
 
78
- def add_end_blocks(self, *blocks:CutsceneBlock):
79
- _ = [block.set_parent_cutscene(self) for block in blocks]
80
- self.end_blocks.extend(blocks)
81
-
82
- def get_scene_at(self, index):
70
+ def get_scene_at(self,index):
83
71
  return bf.CutsceneManager().manager._scenes[index]
84
72
 
85
73
  def get_current_scene(self):
86
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)
87
78
 
88
- def set_scene(self, name, index=0):
89
- return bf.CutsceneManager().manager.set_scene(name, index)
90
-
91
- def get_scene(self, name):
79
+ def get_scene(self,name):
92
80
  return bf.CutsceneManager().manager.get_scene(name)
93
-
94
- def add_block(self, *blocks: CutsceneBlock):
81
+
82
+ def add_block(self, *blocks: list[CutsceneBlock]):
95
83
  for block in blocks:
96
84
  block.set_parent_cutscene(self)
97
85
  self.cutscene_blocks.append(block)
@@ -110,6 +98,7 @@ class Cutscene:
110
98
  def update(self, dt):
111
99
  if self.ended:
112
100
  return
101
+ # print("cutscene update",self.cutscene_blocks[self.block_index])
113
102
  self.cutscene_blocks[self.block_index].update(dt)
114
103
  if self.cutscene_blocks[self.block_index].has_ended():
115
104
  self.block_index += 1
@@ -122,6 +111,9 @@ class Cutscene:
122
111
  self.end_blocks = []
123
112
  self.cutscene_blocks[self.block_index].start()
124
113
 
114
+ # print("NEXT BLOCK")
125
115
 
126
116
  def has_ended(self):
127
117
  return self.ended
118
+
119
+
@@ -1,5 +1,5 @@
1
1
  import batFramework as bf
2
- from .cutscene import Cutscene, CutsceneManager
2
+ from .cutscene import Cutscene,CutsceneManager
3
3
 
4
4
 
5
5
  # Define the base CutsceneBlock class
@@ -17,18 +17,18 @@ class CutsceneBlock:
17
17
  self.ended = False
18
18
  self.started = False
19
19
 
20
- def get_scene_at(self, index):
20
+ def get_scene_at(self,index):
21
21
  return bf.CutsceneManager().manager._scenes[index]
22
22
 
23
- def set_scene(self, name, index=0):
24
- return CutsceneManager().manager.set_scene(name, index)
25
-
23
+ def set_scene(self,name,index=0):
24
+ return CutsceneManager().manager.set_scene(name,index)
25
+
26
26
  def get_current_scene(self):
27
27
  return CutsceneManager().manager.get_current_scene()
28
-
29
- def get_scene(self, name):
28
+
29
+ def get_scene(self,name):
30
30
  return CutsceneManager().manager.get_scene(name)
31
-
31
+
32
32
  # Set the parent cutscene for this block
33
33
  def set_parent_cutscene(self, parent):
34
34
  """
@@ -89,13 +89,18 @@ class ParallelBlock(CutsceneBlock):
89
89
  """
90
90
  Represents a parallel execution block for multiple Cutscene blocks.
91
91
  """
92
+
93
+ # Constructor for ParallelBlock, taking a variable number of blocks as arguments
92
94
  def __init__(self, *blocks) -> None:
93
95
  super().__init__()
94
96
  # List of blocks to run in parallel
95
- self.blocks: list[CutsceneBlock] = list(blocks)
97
+ self.blocks: list[CutsceneBlock] = blocks
96
98
 
97
99
  # Start the parallel block (override the base class method)
98
100
  def start(self):
101
+ """
102
+ Start the parallel execution block.
103
+ """
99
104
  super().start()
100
105
  # Start each block in parallel
101
106
  for block in self.blocks:
@@ -103,14 +108,32 @@ class ParallelBlock(CutsceneBlock):
103
108
 
104
109
  # Process an event for each block in parallel
105
110
  def process_event(self, event):
111
+ """
112
+ Process an event for each block in the parallel execution block.
113
+
114
+ Args:
115
+ event: The event to be processed.
116
+ """
106
117
  _ = [b.process_event(event) for b in self.blocks]
107
118
 
108
119
  # Update each block in parallel
109
120
  def update(self, dt):
121
+ """
122
+ Update each block in the parallel execution block.
123
+
124
+ Args:
125
+ dt: Time elapsed since the last update.
126
+ """
110
127
  _ = [b.update(dt) for b in self.blocks]
111
128
 
112
129
  # Check if all blocks have ended
113
130
  def has_ended(self):
131
+ """
132
+ Check if all blocks in the parallel execution block have ended.
133
+
134
+ Returns:
135
+ bool: True if all blocks have ended, False otherwise.
136
+ """
114
137
  return all(b.has_ended() for b in self.blocks)
115
138
 
116
139
 
@@ -129,7 +152,7 @@ class SceneTransitionBlock(CutsceneBlock):
129
152
  self.duration = duration
130
153
  self.kwargs = kwargs
131
154
  # Timer to handle the end of the transition
132
- self.timer = bf.Timer(duration=duration, end_callback=self.end)
155
+ self.timer = bf.Timer(name = "scene_transition_block",duration=duration, end_callback=self.end)
133
156
 
134
157
  # Start the scene transition block
135
158
  def start(self):
@@ -151,23 +174,3 @@ class SceneTransitionBlock(CutsceneBlock):
151
174
 
152
175
  def end(self):
153
176
  return super().end()
154
-
155
-
156
-
157
- class DelayBlock(CutsceneBlock):
158
- def __init__(self, duration) -> None:
159
- super().__init__()
160
- self.timer = bf.Timer(duration=duration, end_callback=self.end)
161
-
162
- def start(self):
163
- super().start()
164
- self.timer.start()
165
-
166
- class FunctionBlock(CutsceneBlock):
167
- def __init__(self,func)->None:
168
- self.function = func
169
-
170
- def start(self):
171
- super().start()
172
- self.function()
173
- self.end()