batframework 1.0.9a3__py3-none-any.whl → 1.0.9a4__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 CHANGED
@@ -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
+ import batFramework.cutscene
13
+ from .cutsceneManager import CutsceneManager
14
14
  from .audioManager import AudioManager
15
15
  import batFramework.transition as transition
16
16
  from .action import Action
batFramework/cutscene.py CHANGED
@@ -1,129 +1,44 @@
1
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
2
 
60
3
  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()
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()
110
13
  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
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
+
28
+ def end(self):
29
+ self.is_over = True
30
+
31
+
32
+ class Wait(Cutscene):
33
+ def __init__(self,duration:float,scene_name:str="global"):
34
+ super().__init__()
35
+ self.duration = duration
36
+ self.scene_name = scene_name
37
+ def start(self):
38
+ self.timer = bf.SceneTimer(duration=self.duration,end_callback=self.end,scene_name=self.scene_name)
39
+ self.timer.start()
40
+
41
+
42
+
43
+ # class TransitionToScene(bf.Cutscene):
44
+ # def __init__(self,scene_name:str,)
@@ -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
batFramework/enums.py CHANGED
@@ -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
+
batFramework/manager.py CHANGED
@@ -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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batframework
3
- Version: 1.0.9a3
3
+ Version: 1.0.9a4
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
@@ -1,4 +1,4 @@
1
- batFramework/__init__.py,sha256=vcfe0wd5ggzu2NfHoHMfGwMjpBZTPujMt3Fr2W_PWkE,2604
1
+ batFramework/__init__.py,sha256=Fc9uFdDnmhJ1bhCI550T9cu_Zy-ni-avSs5pLmPEgiM,2595
2
2
  batFramework/action.py,sha256=919IVYKviLyVYDtQL7oZvlVuE_aodjJCuwz6fGi5sCk,8420
3
3
  batFramework/actionContainer.py,sha256=qy6-YY3iX26KJ8NqFMSYo6JExohD8HFk0sC1qhb7qA8,2602
4
4
  batFramework/animatedSprite.py,sha256=IWE8zUgpFaqQPUr7iOUo7TJ_E10aUaMNqlIqv8dW87E,4242
@@ -7,20 +7,20 @@ batFramework/audioManager.py,sha256=ANn6GXDm5bcThih0KD8jrF54Re20A6kxHQrVJu9QYxc,
7
7
  batFramework/camera.py,sha256=tSy9n20QLeJD3Uz352q-uejzAHPtQczvahaNz7APJcY,9408
8
8
  batFramework/character.py,sha256=AK5sQLvAOY3X4-7vzeHeIO5WDFsubn_TADLYxmYc0Qo,789
9
9
  batFramework/constants.py,sha256=x8a0GqBJdiwMEjlVohyL3AWHaSxyrBy-4pucVKVNakg,1354
10
- batFramework/cutscene.py,sha256=zra-hvAVY5buBPfFiog4psvLZW07qCt8LZzd7Vd-4qM,3858
11
- batFramework/cutsceneBlocks.py,sha256=3jtmTpV48NKCu-Qgjg7KN5KnwXn0kycIQ7t7G3RH3VE,4862
10
+ batFramework/cutscene.py,sha256=oc6Ktl2t7zO-oH-HWU18wB5ABMyWg7-h3jREGKpcu50,1315
11
+ batFramework/cutsceneManager.py,sha256=mvBR4KOv6KV9eHzhYH7r6IJMVLjM71C30C2OuvwbuSU,945
12
12
  batFramework/drawable.py,sha256=5We2ITq3M5ERG22-iQw7Mo_1LNo0nqma1P13tvphDjY,2197
13
13
  batFramework/dynamicEntity.py,sha256=SjXShy5aT4cQzjlTem05zSQRiNeq52AUXEBVodEG6gI,736
14
14
  batFramework/easingController.py,sha256=ql_nt8unwUZLy7MC7unzDn5eTW44VtjrOTCDs8WS0eY,1750
15
15
  batFramework/entity.py,sha256=wMQKR6IxQ69vtPY4nGsz7WnY9ApPhO_VY08IYx6yUu8,2910
16
- batFramework/enums.py,sha256=r7vAWBm5g3qrvN-WzBN-2ErNKFFqQ5mTrib2GjmDHmE,2083
16
+ batFramework/enums.py,sha256=xkT4yepdLLQn-5YWoSxhHamXE7w_M-GIw47dWWHfKIs,2185
17
17
  batFramework/fontManager.py,sha256=M7h6AVq9Fwr51UTCFoGsg_PSurdjByA4w8qouXq4EKE,2254
18
- batFramework/manager.py,sha256=vu7TfDnJu08_I-pPWSn450NDrMY-LysLe8y3t2fTy_o,4404
18
+ batFramework/manager.py,sha256=TQ0Q1f_GbQE8h4G9zCNQgtNTKNCj630S43Ai4e0yZik,4488
19
19
  batFramework/particle.py,sha256=Aps9eJNdFag-TlduMSezKp4ocFQVvI6iZ98chhdhbgE,3081
20
- batFramework/renderGroup.py,sha256=_VDvmP4iB-XarFJo_Uh5YKwWq1cazHmOBmTXZkqKk40,2020
20
+ batFramework/renderGroup.py,sha256=CO8LtTP1gYI1i_8OwmMk2SlU33Nv4iXnHvK0RVK3D24,2026
21
21
  batFramework/resourceManager.py,sha256=0cOIAFXT7UzzvgHn9QkWcXsTp8H2bIS70NvvgpBL2_4,3554
22
22
  batFramework/scene.py,sha256=0E7omgNUEl5Uhbx8iO3exyCy4p1MC7bSvqfwncW4KMw,11281
23
- batFramework/sceneManager.py,sha256=_VPPi0WepH8_NQuwq6d4gfTFdmku3VxrDkJ8cu3oxqU,7008
23
+ batFramework/sceneManager.py,sha256=GCGt7DYoty_wX2LVEhv0C6TaNyNWhKvWocwOqxUIBXc,7099
24
24
  batFramework/scrollingSprite.py,sha256=_1-hp7y3pC5m8g2VhFVgGOuJsOkOi8adhQiI2Rb0uPY,4133
25
25
  batFramework/sprite.py,sha256=Cz8qzl8jR8y33DUSCObJQOk5e8PcZeavtFhBdR2TogU,1627
26
26
  batFramework/stateMachine.py,sha256=wC-5xbKvf-vGm_N16X9KhgMya5915GyVXL79uk5Bapw,1359
@@ -56,8 +56,8 @@ batFramework/gui/constraints/constraints.py,sha256=XFvrjFFN1nmbYzI6l54DlZkrRP-wW
56
56
  batFramework/templates/__init__.py,sha256=8XN-7JwYFKTRx_lnUL_If3spwgn5_2b7bwmrRRBPON0,46
57
57
  batFramework/templates/character.py,sha256=4UEcegUIeIgj48sVgzyRcT6yjpFOZ8Q_gHTtiB5j6kw,1348
58
58
  batFramework/templates/states.py,sha256=WeomVrQ10vHxVCj9Wnk1PcinKyb871uV910mQe287kI,5370
59
- batframework-1.0.9a3.dist-info/LICENCE,sha256=A65iXbMDbOxQLDNOODJLqA7o5RxszYlEqIgNSzBQRf4,1073
60
- batframework-1.0.9a3.dist-info/METADATA,sha256=UpbSgm9XCqqMyFjRrXOdmPHYD70b-BW0SPVzedEvmCk,1694
61
- batframework-1.0.9a3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
62
- batframework-1.0.9a3.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
63
- batframework-1.0.9a3.dist-info/RECORD,,
59
+ batframework-1.0.9a4.dist-info/LICENCE,sha256=A65iXbMDbOxQLDNOODJLqA7o5RxszYlEqIgNSzBQRf4,1073
60
+ batframework-1.0.9a4.dist-info/METADATA,sha256=JIZ73b5rzLH38fgZtEOrFNIVvQpMoI5dpT0Y7CZJ5iU,1694
61
+ batframework-1.0.9a4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
62
+ batframework-1.0.9a4.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
63
+ batframework-1.0.9a4.dist-info/RECORD,,
@@ -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()