batframework 1.0.9a3__tar.gz → 1.0.9a5__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.
Files changed (70) hide show
  1. {batframework-1.0.9a3 → batframework-1.0.9a5}/PKG-INFO +1 -1
  2. {batframework-1.0.9a3 → batframework-1.0.9a5}/pyproject.toml +1 -1
  3. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/__init__.py +2 -2
  4. batframework-1.0.9a5/src/batFramework/cutscene.py +53 -0
  5. batframework-1.0.9a5/src/batFramework/cutsceneManager.py +31 -0
  6. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/enums.py +7 -1
  7. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/label.py +4 -7
  8. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/styleManager.py +1 -1
  9. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/manager.py +2 -0
  10. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/renderGroup.py +3 -3
  11. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/sceneManager.py +3 -0
  12. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/scrollingSprite.py +3 -7
  13. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batframework.egg-info/PKG-INFO +1 -1
  14. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batframework.egg-info/SOURCES.txt +1 -1
  15. batframework-1.0.9a3/src/batFramework/cutscene.py +0 -129
  16. batframework-1.0.9a3/src/batFramework/cutsceneBlocks.py +0 -169
  17. {batframework-1.0.9a3 → batframework-1.0.9a5}/LICENCE +0 -0
  18. {batframework-1.0.9a3 → batframework-1.0.9a5}/README.md +0 -0
  19. {batframework-1.0.9a3 → batframework-1.0.9a5}/setup.cfg +0 -0
  20. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/action.py +0 -0
  21. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/actionContainer.py +0 -0
  22. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/animatedSprite.py +0 -0
  23. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/animation.py +0 -0
  24. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/audioManager.py +0 -0
  25. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/camera.py +0 -0
  26. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/character.py +0 -0
  27. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/constants.py +0 -0
  28. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/drawable.py +0 -0
  29. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/dynamicEntity.py +0 -0
  30. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/easingController.py +0 -0
  31. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/entity.py +0 -0
  32. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/fontManager.py +0 -0
  33. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/__init__.py +0 -0
  34. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/animatedLabel.py +0 -0
  35. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/button.py +0 -0
  36. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/clickableWidget.py +0 -0
  37. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/constraints/__init__.py +0 -0
  38. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/constraints/constraints.py +0 -0
  39. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/container.py +0 -0
  40. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/debugger.py +0 -0
  41. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/draggableWidget.py +0 -0
  42. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/image.py +0 -0
  43. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/indicator.py +0 -0
  44. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/interactiveWidget.py +0 -0
  45. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/layout.py +0 -0
  46. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/meter.py +0 -0
  47. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/radioButton.py +0 -0
  48. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/root.py +0 -0
  49. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/shape.py +0 -0
  50. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/slider.py +0 -0
  51. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/style.py +0 -0
  52. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/textInput.py +0 -0
  53. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/toggle.py +0 -0
  54. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/gui/widget.py +0 -0
  55. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/particle.py +0 -0
  56. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/resourceManager.py +0 -0
  57. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/scene.py +0 -0
  58. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/sprite.py +0 -0
  59. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/stateMachine.py +0 -0
  60. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/templates/__init__.py +0 -0
  61. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/templates/character.py +0 -0
  62. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/templates/states.py +0 -0
  63. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/tileset.py +0 -0
  64. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/timeManager.py +0 -0
  65. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/transition.py +0 -0
  66. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/triggerZone.py +0 -0
  67. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batFramework/utils.py +0 -0
  68. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batframework.egg-info/dependency_links.txt +0 -0
  69. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batframework.egg-info/requires.txt +0 -0
  70. {batframework-1.0.9a3 → batframework-1.0.9a5}/src/batframework.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batframework
3
- Version: 1.0.9a3
3
+ Version: 1.0.9a5
4
4
  Summary: Pygame framework for making games easier.
5
5
  Author-email: Turan Baturay <baturayturan@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/TuranBaturay/batFramework
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "batframework"
7
- version = "1.0.9a3"
7
+ version = "1.0.9a5"
8
8
  description = "Pygame framework for making games easier."
9
9
  readme = "README.md"
10
10
  classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
@@ -9,8 +9,8 @@ from .utils import Utils as utils
9
9
  from .tileset import Tileset
10
10
  from .timeManager import TimeManager,Timer,SceneTimer
11
11
  from .easingController import EasingController
12
- from .cutscene import Cutscene, CutsceneManager
13
- import batFramework.cutsceneBlocks
12
+ from .cutsceneManager import CutsceneManager
13
+ from .cutscene import *
14
14
  from .audioManager import AudioManager
15
15
  import batFramework.transition as transition
16
16
  from .action import Action
@@ -0,0 +1,53 @@
1
+ import batFramework as bf
2
+ from .transition import Transition
3
+ class Cutscene:
4
+ def __init__(self,*cutscenes):
5
+ self.is_over : bool = False
6
+ self.sub_cutscenes : list[Cutscene] = list(cutscenes)
7
+ self.sub_index = -1
8
+
9
+ def start(self):
10
+ if self.sub_cutscenes:
11
+ self.sub_index = 0
12
+ self.sub_cutscenes[self.sub_index].start()
13
+ else:
14
+ self.end()
15
+
16
+ def process_event(self,event):
17
+ if self.sub_index > 0:
18
+ self.sub_cutscenes[self.sub_index].process_event(event)
19
+
20
+ def update(self,dt):
21
+ if self.sub_index >= 0:
22
+ self.sub_cutscenes[self.sub_index].update(dt)
23
+ if self.sub_cutscenes[self.sub_index].is_over:
24
+ self.sub_index +=1
25
+ if self.sub_index >= len(self.sub_cutscenes):
26
+ self.end()
27
+ return
28
+ self.sub_cutscenes[self.sub_index].start()
29
+
30
+ def end(self):
31
+ self.is_over = True
32
+
33
+
34
+ class Wait(Cutscene):
35
+ def __init__(self,duration:float,scene_name:str="global"):
36
+ super().__init__()
37
+ self.duration = duration
38
+ self.scene_name = scene_name
39
+ def start(self):
40
+ self.timer = bf.SceneTimer(duration=self.duration,end_callback=self.end,scene_name=self.scene_name)
41
+ self.timer.start()
42
+
43
+
44
+
45
+ class TransitionToScene(Cutscene):
46
+ def __init__(self,scene_name:str,transition:Transition):
47
+ super().__init__()
48
+ self.scene_name = scene_name
49
+ self.transition: Transition = transition
50
+
51
+ def start(self):
52
+ bf.CutsceneManager().manager.transition_to_scene(self.scene_name,self.transition)
53
+ bf.Timer(self.transition.duration,end_callback=self.end).start()
@@ -0,0 +1,31 @@
1
+ import batFramework as bf
2
+ from typing import TYPE_CHECKING,Self
3
+ import pygame
4
+ # if TYPE_CHECKING:
5
+ from .cutscene import Cutscene
6
+
7
+
8
+ class CutsceneManager(metaclass=bf.Singleton):
9
+ def __init__(self) -> None:
10
+ self.current_cutscene: Cutscene = None
11
+ self.manager: bf.Manager = None
12
+
13
+ def set_manager(self, manager):
14
+ self.manager = manager
15
+
16
+ def process_event(self, event):
17
+ if self.current_cutscene is not None:
18
+ self.current_cutscene.process_event(event)
19
+ if event.type in bf.enums.playerInput:
20
+ event.consumed = True
21
+
22
+ def play(self,cutscene:Cutscene):
23
+ if self.current_cutscene is not None:return
24
+ self.current_cutscene = cutscene
25
+ cutscene.start()
26
+
27
+ def update(self,dt):
28
+ if self.current_cutscene:
29
+ self.current_cutscene.update(dt)
30
+ if self.current_cutscene.is_over:
31
+ self.current_cutscene = None
@@ -1,4 +1,8 @@
1
1
  from enum import Enum
2
+ import pygame
3
+
4
+ playerInput = [pygame.KEYDOWN,pygame.MOUSEBUTTONDOWN,pygame.KEYUP,pygame.MOUSEBUTTONUP]
5
+
2
6
 
3
7
 
4
8
  class color:
@@ -111,4 +115,6 @@ class textMode(Enum):
111
115
  ALPHABETICAL = 0
112
116
  NUMERICAL = 1
113
117
  ALPHANUMERICAL = 3
114
-
118
+
119
+
120
+
@@ -246,9 +246,9 @@ class Label(Shape):
246
246
 
247
247
  def _build_layout(self) -> None:
248
248
 
249
+ # print(self.text_rect.size,self._get_text_rect_required_size(),repr(self.text))
249
250
  self.text_rect.size = self._get_text_rect_required_size()
250
- # self.text_rect.w = ceil(self.text_rect.w)
251
- # self.text_rect.h = ceil(self.text_rect.h)
251
+
252
252
  if self.autoresize_h or self.autoresize_w:
253
253
  target_rect = self.inflate_rect_by_padding((0, 0, *self.text_rect.size))
254
254
  if not self.autoresize_w:
@@ -256,9 +256,10 @@ class Label(Shape):
256
256
  if not self.autoresize_h:
257
257
  target_rect.h = self.rect.h
258
258
  if self.rect.size != target_rect.size:
259
+ # print("Size not good ! ",self.rect.size,target_rect.size,repr(self.text))
259
260
  self.set_size(target_rect.size)
260
261
  self.apply_updates()
261
- return
262
+
262
263
  offset = self._get_outline_offset() if self.show_text_outline else (0,0)
263
264
  padded = self.get_padded_rect().move(-self.rect.x + offset[0], -self.rect.y + offset[1])
264
265
  self.align_text(self.text_rect, padded, self.alignment)
@@ -271,7 +272,6 @@ class Label(Shape):
271
272
  if self.font_object is None:
272
273
  print(f"No font for widget with text : '{self}' :(")
273
274
  return
274
-
275
275
  params = {
276
276
  "font_name": self.font_object.name,
277
277
  "text": self.text,
@@ -333,6 +333,3 @@ class Label(Shape):
333
333
  super().paint()
334
334
  if self.font_object:
335
335
  self._paint_text()
336
-
337
- # def set_alignment(self, alignment: bf.alignment) -> Self:
338
- # return self
@@ -25,7 +25,7 @@ class StyleManager(metaclass=Singleton):
25
25
 
26
26
  def refresh_widget(self, widget: Widget):
27
27
  if widget in self.widgets:
28
- self.lookup[widget] = True
28
+ self.lookup[widget] = False
29
29
  self.update()
30
30
 
31
31
  def remove_widget(self, widget: Widget):
@@ -74,6 +74,8 @@ class Manager(bf.SceneManager):
74
74
  if event.key == pygame.K_p:
75
75
  self.print_status()
76
76
  return
77
+ self.cutsceneManager.process_event(event)
78
+ if event.consumed: return
77
79
  super().process_event(event)
78
80
  if not event.consumed:
79
81
  if event.type == pygame.QUIT:
@@ -8,13 +8,13 @@ from typing import Self, Iterator, Callable
8
8
  """
9
9
 
10
10
 
11
- class RenderGroup(bf.Entity):
11
+ class RenderGroup(bf.Drawable):
12
12
  def __init__(
13
- self, entity_iterator: Callable[[], Iterator[bf.Entity]], blit_flags: int = 0
13
+ self, entity_iterator: Callable[[], Iterator[bf.Drawable]], blit_flags: int = 0
14
14
  ) -> None:
15
15
  super().__init__()
16
16
  self.entity_iterator = entity_iterator
17
- self.set_blit_flags(blit_flags)
17
+ # self.set_blit_flags(blit_flags)
18
18
  self.set_debug_color("white")
19
19
 
20
20
  def get_debug_outlines(self):
@@ -171,6 +171,9 @@ class SceneManager:
171
171
 
172
172
  def process_event(self, event: pygame.Event):
173
173
 
174
+ if self.current_transitions and event in bf.enums.playerInput:
175
+ return
176
+
174
177
  if event.type in self.shared_events:
175
178
  [s.process_event(event) for s in self.scenes]
176
179
  else:
@@ -17,19 +17,15 @@ class ScrollingSprite(bf.Sprite):
17
17
  # Use integer values for the starting points, converted from floating point scroll values
18
18
 
19
19
  super().__init__(size, data, convert_alpha)
20
- self.original_width, self.original_height = self.original_surface.get_size()
20
+ if self.original_surface:
21
+ self.original_width, self.original_height = self.original_surface.get_size()
22
+
21
23
 
22
24
  def get_debug_outlines(self):
23
25
  yield from super().get_debug_outlines()
24
26
  for r in self._get_mosaic_rect_list():
25
27
  yield r.move(*self.rect.topleft)
26
28
 
27
- def set_image(
28
- self, data: pygame.Surface | str, size: None | tuple[int, int] = None
29
- ) -> Self:
30
- super().set_image(data, size)
31
- self.original_width, self.original_height = self.original_surface.get_size()
32
- return self
33
29
 
34
30
  def set_autoscroll(self, x: float, y: float) -> Self:
35
31
  self.auto_scroll.update(x, y)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batframework
3
- Version: 1.0.9a3
3
+ Version: 1.0.9a5
4
4
  Summary: Pygame framework for making games easier.
5
5
  Author-email: Turan Baturay <baturayturan@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/TuranBaturay/batFramework
@@ -11,7 +11,7 @@ src/batFramework/camera.py
11
11
  src/batFramework/character.py
12
12
  src/batFramework/constants.py
13
13
  src/batFramework/cutscene.py
14
- src/batFramework/cutsceneBlocks.py
14
+ src/batFramework/cutsceneManager.py
15
15
  src/batFramework/drawable.py
16
16
  src/batFramework/dynamicEntity.py
17
17
  src/batFramework/easingController.py
@@ -1,129 +0,0 @@
1
- import batFramework as bf
2
- from typing import TYPE_CHECKING,Self
3
-
4
- class CutsceneBlock: ...
5
-
6
- if TYPE_CHECKING:
7
- from .cutsceneBlocks import CutsceneBlock
8
-
9
-
10
- class Cutscene: ...
11
-
12
-
13
- class CutsceneManager(metaclass=bf.Singleton):
14
- def __init__(self) -> None:
15
- 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
21
-
22
- def get_flag(self, flag):
23
- return None
24
-
25
- def process_event(self, event):
26
- if self.current_cutscene:
27
- self.current_cutscene.process_event(event)
28
-
29
- def queue(self, *cutscenes):
30
- self.cutscenes.extend(cutscenes)
31
- if self.current_cutscene is None:
32
- self.play(self.cutscenes.pop(0))
33
-
34
- def play(self, cutscene: Cutscene):
35
- if self.current_cutscene is None:
36
- self.current_cutscene = cutscene
37
- self.current_cutscene.on_enter()
38
- self.current_cutscene.init_blocks()
39
- self.current_cutscene.play()
40
-
41
- def enable_player_control(self) -> None:
42
- pass
43
-
44
- def disable_player_control(self) -> None:
45
- pass
46
-
47
- def update(self, dt):
48
- if not self.current_cutscene is None:
49
- self.current_cutscene.update(dt)
50
- # print("cutscene manager update")
51
- if self.current_cutscene.has_ended():
52
- self.current_cutscene.on_exit()
53
- self.current_cutscene = None
54
- if self.cutscenes:
55
- self.play(self.cutscenes.pop(0))
56
- else:
57
- self.current_cutscene = None
58
-
59
-
60
- class Cutscene:
61
- def __init__(self) -> None:
62
- self.cutscene_blocks : list[CutsceneBlock] = []
63
- self.block_index = 0
64
- self.end_blocks: list[CutsceneBlock] = []
65
- self.ended = False
66
-
67
- def on_enter(self):
68
- pass
69
-
70
- def on_exit(self):
71
- pass
72
-
73
- def init_blocks(self):
74
- pass
75
-
76
- def add_blocks(self, *blocks: CutsceneBlock)->Self:
77
- self.cutscene_blocks.extend(blocks)
78
- return self
79
-
80
- def add_end_blocks(self, *blocks: CutsceneBlock)->Self:
81
- _ = [block.set_parent_cutscene(self) for block in blocks]
82
- self.end_blocks.extend(blocks)
83
- return self
84
-
85
- def get_scene_at(self, index):
86
- return bf.CutsceneManager().manager.scenes[index]
87
-
88
- def get_current_scene(self):
89
- return bf.CutsceneManager().manager.get_current_scene()
90
-
91
- def set_scene(self, name, index=0):
92
- return bf.CutsceneManager().manager.set_scene(name, index)
93
-
94
- def get_scene(self, name):
95
- return bf.CutsceneManager().manager.get_scene(name)
96
-
97
- def add_block(self, *blocks: CutsceneBlock):
98
- for block in blocks:
99
- block.set_parent_cutscene(self)
100
- self.cutscene_blocks.append(block)
101
-
102
- def process_event(self, event):
103
- if not self.ended and self.block_index < len(self.cutscene_blocks):
104
- self.cutscene_blocks[self.block_index].process_event(event)
105
-
106
- def play(self):
107
- self.block_index = 0
108
- if self.cutscene_blocks:
109
- self.cutscene_blocks[self.block_index].start()
110
- else:
111
- self.ended
112
-
113
- def update(self, dt):
114
- if self.ended:
115
- return
116
- self.cutscene_blocks[self.block_index].update(dt)
117
- if self.cutscene_blocks[self.block_index].has_ended():
118
- self.block_index += 1
119
- if self.block_index == len(self.cutscene_blocks):
120
- if not self.end_blocks:
121
- self.ended = True
122
- return
123
- else:
124
- self.cutscene_blocks.extend(self.end_blocks)
125
- self.end_blocks = []
126
- self.cutscene_blocks[self.block_index].start()
127
-
128
- def has_ended(self):
129
- return self.ended
@@ -1,169 +0,0 @@
1
- import batFramework as bf
2
- from .cutscene import Cutscene, CutsceneManager
3
- from .transition import *
4
- from typing import Optional,Callable
5
-
6
- # Define the base CutsceneBlock class
7
- class CutsceneBlock:
8
- """
9
- Base class for cutscene blocks. Represents a unit of action in a cutscene.
10
- """
11
-
12
- # Constructor for the CutsceneBlock
13
- def __init__(self) -> None:
14
- # Callback function, parent cutscene, and state variables
15
- self.callback = None
16
- self.parent_cutscene: Cutscene = None
17
- self.get_flag = CutsceneManager().get_flag
18
- self.ended = False
19
- self.started = False
20
-
21
- def get_scene_at(self, index):
22
- return bf.CutsceneManager().manager.scenes[index]
23
-
24
- def set_scene(self, name, index=0):
25
- return CutsceneManager().manager.set_scene(name, index)
26
-
27
- def get_current_scene(self):
28
- return CutsceneManager().manager.get_current_scene()
29
-
30
- def get_scene(self, name):
31
- return CutsceneManager().manager.get_scene(name)
32
-
33
- # Set the parent cutscene for this block
34
- def set_parent_cutscene(self, parent):
35
- """
36
- Set the parent cutscene for this block.
37
-
38
- Args:
39
- parent: The parent cutscene object.
40
- """
41
- self.parent_cutscene = parent
42
-
43
- # Process an event (placeholder implementation, to be overridden in subclasses)
44
- def process_event(self, event):
45
- """
46
- Process an event for this cutscene block.
47
-
48
- Args:
49
- event: The event to be processed.
50
- """
51
- pass
52
-
53
- # Update the block (placeholder implementation, to be overridden in subclasses)
54
- def update(self, dt):
55
- """
56
- Update the cutscene block.
57
-
58
- Args:
59
- dt: Time elapsed since the last update.
60
- """
61
- pass
62
-
63
- # Start the block
64
- def start(self):
65
- """
66
- Start the cutscene block.
67
- """
68
- self.started = True
69
-
70
- # Mark the block as ended
71
- def end(self):
72
- """
73
- Mark the cutscene block as ended.
74
- """
75
- self.ended = True
76
-
77
- # Check if the block has ended
78
- def has_ended(self):
79
- """
80
- Check if the cutscene block has ended.
81
-
82
- Returns:
83
- bool: True if the block has ended, False otherwise.
84
- """
85
- return self.ended
86
-
87
-
88
- # Define the ParallelBlock class, a type of CutsceneBlock
89
- class ParallelBlock(CutsceneBlock):
90
- """
91
- Represents a parallel execution block for multiple Cutscene blocks.
92
- """
93
-
94
- def __init__(self, *blocks) -> None:
95
- super().__init__()
96
- # List of blocks to run in parallel
97
- self.blocks: list[CutsceneBlock] = list(blocks)
98
-
99
- # Start the parallel block (override the base class method)
100
- def start(self):
101
- super().start()
102
- # Start each block in parallel
103
- for block in self.blocks:
104
- block.start()
105
-
106
- # Process an event for each block in parallel
107
- def process_event(self, event):
108
- _ = [b.process_event(event) for b in self.blocks]
109
-
110
- # Update each block in parallel
111
- def update(self, dt):
112
- _ = [b.update(dt) for b in self.blocks]
113
-
114
- # Check if all blocks have ended
115
- def has_ended(self):
116
- return all(b.has_ended() for b in self.blocks)
117
-
118
-
119
- # Define the SceneTransitionBlock class, a type of CutsceneBlock
120
- class SceneTransitionBlock(CutsceneBlock):
121
- """
122
- Represents a scene transition Cutscene block.
123
- """
124
-
125
- # Constructor for SceneTransitionBlock
126
- def __init__(
127
- self, scene, transition: Transition = Fade(0.1), index: int = 0
128
- ) -> None:
129
- super().__init__()
130
- # Target scene, transition type, duration, and additional keyword arguments
131
- self.target_scene = scene
132
- self.transition = transition
133
- self.index = index
134
- # Timer to handle the end of the transition
135
- self.timer = bf.Timer(transition.duration, self.end)
136
-
137
- # Start the scene transition block
138
- def start(self):
139
- """
140
- Start the scene transition block.
141
- """
142
- super().start()
143
- # Initiate the scene transition
144
- if self.get_current_scene().name == self.target_scene:
145
- self.end()
146
- return
147
- CutsceneManager().manager.transition_to_scene(
148
- self.target_scene, self.transition, self.index
149
- )
150
- # Start the timer to handle the end of the transition
151
- self.timer.start()
152
-
153
- class DelayBlock(CutsceneBlock):
154
- def __init__(self, duration) -> None:
155
- super().__init__()
156
- self.timer = bf.Timer(duration=duration, end_callback=self.end)
157
-
158
- def start(self):
159
- super().start()
160
- self.timer.start()
161
-
162
- class FunctionBlock(CutsceneBlock):
163
- def __init__(self, func : Optional[Callable]) -> None:
164
- self.function = func
165
-
166
- def start(self):
167
- super().start()
168
- if self.function : self.function()
169
- self.end()
File without changes
File without changes
File without changes