batframework 1.0.8a2__py3-none-any.whl → 1.0.8a4__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 (65) hide show
  1. batFramework/__init__.py +53 -50
  2. batFramework/action.py +126 -99
  3. batFramework/actionContainer.py +53 -9
  4. batFramework/animatedSprite.py +117 -73
  5. batFramework/audioManager.py +69 -26
  6. batFramework/camera.py +259 -69
  7. batFramework/constants.py +16 -54
  8. batFramework/cutscene.py +39 -29
  9. batFramework/cutsceneBlocks.py +36 -43
  10. batFramework/dynamicEntity.py +17 -9
  11. batFramework/easingController.py +58 -0
  12. batFramework/entity.py +48 -97
  13. batFramework/enums.py +113 -0
  14. batFramework/fontManager.py +65 -0
  15. batFramework/gui/__init__.py +10 -2
  16. batFramework/gui/button.py +9 -78
  17. batFramework/gui/clickableWidget.py +221 -0
  18. batFramework/gui/constraints/__init__.py +1 -0
  19. batFramework/gui/constraints/constraints.py +730 -0
  20. batFramework/gui/container.py +174 -32
  21. batFramework/gui/debugger.py +131 -43
  22. batFramework/gui/dialogueBox.py +99 -0
  23. batFramework/gui/draggableWidget.py +40 -0
  24. batFramework/gui/image.py +54 -18
  25. batFramework/gui/indicator.py +38 -21
  26. batFramework/gui/interactiveWidget.py +177 -13
  27. batFramework/gui/label.py +292 -74
  28. batFramework/gui/layout.py +219 -60
  29. batFramework/gui/meter.py +71 -0
  30. batFramework/gui/radioButton.py +84 -0
  31. batFramework/gui/root.py +134 -38
  32. batFramework/gui/shape.py +259 -57
  33. batFramework/gui/slider.py +230 -0
  34. batFramework/gui/style.py +10 -0
  35. batFramework/gui/styleManager.py +48 -0
  36. batFramework/gui/textInput.py +137 -0
  37. batFramework/gui/toggle.py +103 -51
  38. batFramework/gui/widget.py +329 -254
  39. batFramework/manager.py +40 -19
  40. batFramework/object.py +114 -0
  41. batFramework/particle.py +101 -0
  42. batFramework/renderGroup.py +67 -0
  43. batFramework/resourceManager.py +100 -0
  44. batFramework/scene.py +281 -123
  45. batFramework/sceneManager.py +141 -108
  46. batFramework/scrollingSprite.py +114 -0
  47. batFramework/sprite.py +51 -0
  48. batFramework/stateMachine.py +2 -2
  49. batFramework/tileset.py +46 -0
  50. batFramework/time.py +123 -58
  51. batFramework/transition.py +195 -124
  52. batFramework/utils.py +87 -151
  53. batframework-1.0.8a4.dist-info/LICENCE +21 -0
  54. batframework-1.0.8a4.dist-info/METADATA +55 -0
  55. batframework-1.0.8a4.dist-info/RECORD +58 -0
  56. batFramework/debugger.py +0 -48
  57. batFramework/easing.py +0 -71
  58. batFramework/gui/constraints.py +0 -204
  59. batFramework/gui/frame.py +0 -19
  60. batFramework/particles.py +0 -77
  61. batFramework/transitionManager.py +0 -0
  62. batframework-1.0.8a2.dist-info/METADATA +0 -58
  63. batframework-1.0.8a2.dist-info/RECORD +0 -42
  64. {batframework-1.0.8a2.dist-info → batframework-1.0.8a4.dist-info}/WHEEL +0 -0
  65. {batframework-1.0.8a2.dist-info → batframework-1.0.8a4.dist-info}/top_level.txt +0 -0
@@ -1,204 +0,0 @@
1
- from .widget import Widget
2
- import batFramework as bf
3
-
4
-
5
- class Constraint:
6
- def __init__(self,name="Constraint", priority=0):
7
- self.priority = priority
8
- self.name = name
9
- def set_priority(self, priority)->"Constraint":
10
- self.priority = priority
11
- return self
12
- def to_string(self)->str:
13
- return f"{self.name.upper()}"
14
-
15
- def evaluate(self, parent_widget:Widget, child_widget:Widget) -> bool:
16
- raise NotImplementedError("Subclasses must implement evaluate method")
17
-
18
- def apply(self, parent_widget:Widget, child_widget:Widget=None) -> bool:
19
- if not self.evaluate(parent_widget, child_widget):
20
- self.apply_constraint(parent_widget, child_widget)
21
- return False
22
- return True
23
-
24
- def apply_constraint(self, parent_widget:Widget, child_widget:Widget):
25
- raise NotImplementedError("Subclasses must implement apply_constraint method")
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
- class ConstraintMinWidth(Constraint):
43
- def __init__(self, width):
44
- super().__init__(name="min_width")
45
- self.min_width = width
46
-
47
- def evaluate(self, parent_widget, child_widget):
48
- return child_widget.rect.width >= self.min_width
49
-
50
- def apply_constraint(self, parent_widget, child_widget):
51
- if not self.evaluate(parent_widget, child_widget):
52
- child_widget.set_size(self.min_width,child_widget.rect.h)
53
-
54
-
55
-
56
-
57
- class ConstraintCenterX(Constraint):
58
- def __init__(self):
59
- super().__init__(name="centerx")
60
-
61
- def evaluate(self, parent_widget, child_widget):
62
- return child_widget.rect.centerx == parent_widget.get_content_center()[0]
63
-
64
- def apply_constraint(self,parent_widget,child_widget):
65
- if not self.evaluate(parent_widget,child_widget):
66
- child_widget.set_center(parent_widget.get_content_center()[0],child_widget.rect.centery)
67
-
68
- class ConstraintCenterY(Constraint):
69
- def __init__(self):
70
- super().__init__(name="centery")
71
-
72
- def evaluate(self, parent_widget, child_widget):
73
- return child_widget.rect.centery == parent_widget.get_content_center()[1]
74
-
75
- def apply_constraint(self,parent_widget,child_widget):
76
- if not self.evaluate(parent_widget,child_widget):
77
- child_widget.set_center(child_widget.rect.centerx,parent_widget.get_content_center()[1])
78
-
79
- class ConstraintCenter(Constraint):
80
- def __init__(self):
81
- super().__init__(name="center")
82
-
83
- def evaluate(self, parent_widget, child_widget):
84
- return child_widget.rect.center == parent_widget.get_content_center()
85
-
86
- def apply_constraint(self,parent_widget,child_widget):
87
- if not self.evaluate(parent_widget,child_widget):
88
- child_widget.set_center(*parent_widget.get_content_center())
89
-
90
- class ConstraintPercentageWidth(Constraint):
91
- def __init__(self,percentage:float,keep_autoresize:bool=True):
92
- super().__init__(name="percentage_width")
93
- self.percentage:float = percentage
94
- self.keep_autoresize: bool = keep_autoresize
95
- def to_string(self)->str:
96
- return f"{super().to_string()}.[{self.percentage},{self.keep_autoresize}]"
97
- def evaluate(self, parent_widget, child_widget):
98
- return child_widget.rect.width == round(parent_widget.get_content_width() * self.percentage)
99
-
100
- def apply_constraint(self,parent_widget,child_widget):
101
- if not self.evaluate(parent_widget,child_widget):
102
- if child_widget.autoresize:
103
- if self.keep_autoresize:
104
- print(f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True")
105
- return
106
- child_widget.set_autoresize(False)
107
- child_widget.set_size(round(parent_widget.get_content_width() * self.percentage) ,child_widget.rect.h)
108
-
109
-
110
- class ConstraintPercentageHeight(Constraint):
111
- def __init__(self,percentage:float,keep_autoresize:bool=True):
112
- super().__init__(name="percentage_height")
113
- self.percentage:float = percentage
114
- self.keep_autoresize: bool = keep_autoresize
115
-
116
- def evaluate(self, parent_widget, child_widget):
117
- return child_widget.rect.height == round(parent_widget.get_content_height() * self.percentage)
118
-
119
- def apply_constraint(self,parent_widget,child_widget):
120
- if not self.evaluate(parent_widget,child_widget):
121
- if child_widget.autoresize:
122
- if self.keep_autoresize:
123
- print(f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True")
124
- return
125
- child_widget.set_autoresize(False)
126
- child_widget.set_size(child_widget.rect.w,round(parent_widget.get_content_height() * self.percentage))
127
-
128
- class ConstraintHeight(Constraint):
129
- def __init__(self,height:float):
130
- if height < 0 :
131
- raise ValueError("height can't be negative")
132
- super().__init__(name="height")
133
- self.height = height
134
-
135
- def to_string(self)->str:
136
- return f"{super().to_string()}.({self.height})"
137
-
138
- def evaluate(self, parent_widget, child_widget):
139
- return child_widget.rect.height == self.height
140
-
141
- def apply_constraint(self,parent_widget,child_widget):
142
- if not self.evaluate(parent_widget,child_widget):
143
- child_widget.set_size(child_widget.rect.w,self.height)
144
-
145
- class ConstraintWidth(Constraint):
146
- def __init__(self,width:float):
147
- if width < 0 :
148
- raise ValueError("width can't be negative")
149
- super().__init__(name="width")
150
- self.width = width
151
-
152
- def to_string(self)->str:
153
- return f"{super().to_string()}.({self.width})"
154
-
155
- def evaluate(self, parent_widget, child_widget):
156
- return child_widget.rect.width == self.width
157
-
158
- def apply_constraint(self,parent_widget,child_widget):
159
- if not self.evaluate(parent_widget,child_widget):
160
- child_widget.set_size(self.width,child_widget.rect.h)
161
-
162
-
163
- class ConstraintAspectRatio(Constraint):
164
- def __init__(self,ratio:int|float=1):
165
- super().__init__(name="aspect_ratio")
166
- if isinstance(ratio, float|int):
167
- self.ratio = ratio
168
- elif isinstance(ratio,Widget):
169
- self.ratio = ratio.rect.w / ratio.rect.h
170
- else:
171
- raise TypeError(f"Ratio must be float or Widget")
172
- def evaluate(self, parent_widget,child_widget):
173
- return self.ratio == child_widget.rect.w / child_widget.rect.h
174
-
175
- def apply_constraint(self,parent_widget,child_widget):
176
- if not self.evaluate(parent_widget,child_widget):
177
- return # TODO
178
-
179
- class ConstraintAnchorBottom(Constraint):
180
- def __init__(self):
181
- super().__init__(name="anchor_bottom")
182
-
183
- def evaluate(self, parent_widget,child_widget):
184
- return child_widget.rect.bottom == parent_widget.rect.bottom
185
-
186
- def apply_constraint(self,parent_widget,child_widget):
187
- if not self.evaluate(parent_widget,child_widget):
188
- child_widget.set_y(parent_widget.get_content_bottom() - child_widget.rect.h)
189
-
190
-
191
- class ConstraintAnchorTopRight(Constraint):
192
- def __init__(self):
193
- super().__init__(name="anchor_topright")
194
-
195
- def evaluate(self, parent_widget,child_widget):
196
- return child_widget.rect.topright == parent_widget.rect.topright
197
-
198
- def apply_constraint(self,parent_widget,child_widget):
199
- if not self.evaluate(parent_widget,child_widget):
200
- child_widget.set_position(parent_widget.get_content_right()-child_widget.rect.w, parent_widget.get_content_top())
201
-
202
-
203
-
204
-
batFramework/gui/frame.py DELETED
@@ -1,19 +0,0 @@
1
- import batFramework as bf
2
- from .shape import Shape
3
- import pygame
4
-
5
-
6
- class Frame(Shape):
7
- def __init__(self,width:float,height:float):
8
- super().__init__(width,height)
9
- self.set_debug_color("magenta")
10
-
11
- def to_string_id(self)->str:
12
- return "Frame"
13
-
14
- def children_modified(self)->None:
15
- print(self.children)
16
- self.set_size(
17
- *self.inflate_rect_by_padding(self.rect.unionall(list(c.rect for c in self.children))).size
18
- )
19
- super().children_modified()
batFramework/particles.py DELETED
@@ -1,77 +0,0 @@
1
- import batFramework as bf
2
- import pygame
3
- from pygame.math import Vector2
4
-
5
-
6
- class Particle:
7
- def __init__(
8
- self,
9
- start_pos: tuple[float, float],
10
- start_vel: tuple[float, float],
11
- duration=1000,
12
- color=None,
13
- size = (4,4)
14
- ):
15
- self.rect = pygame.FRect(*start_pos, 0, 0)
16
- self.surface = pygame.Surface(size).convert()
17
- if color:
18
- self.surface.fill(color)
19
- self.velocity = Vector2(*start_vel)
20
- self.start_time = pygame.time.get_ticks()
21
- self.duration = duration
22
- self.dead = False
23
- self.progression = 0
24
- self.z_depth = 1
25
-
26
- def update(self, dt):
27
- if self.dead:
28
- return
29
- elapsed_time = pygame.time.get_ticks() - self.start_time
30
- self.progression = elapsed_time / self.duration
31
- self.dead = elapsed_time >= self.duration
32
- self.rect.center += self.velocity * dt
33
- self.update_surface()
34
-
35
- def kill(self):
36
- self.dead = True
37
-
38
- def update_surface(self):
39
- self.surface.set_alpha(255 - int(self.progression * 255))
40
-
41
-
42
- class ParticleManager(bf.Entity):
43
- def __init__(self) -> None:
44
- super().__init__(size=bf.const.RESOLUTION)
45
- self.particles: list[Particle] = []
46
-
47
- def get_bounding_box(self):
48
- for particle in self.particles:
49
- yield particle.rect
50
-
51
- def add_particle(self, particle_class=Particle, **kwargs):
52
- self.particles.append(particle_class(**kwargs))
53
-
54
-
55
- def clear(self):
56
- self.particles = []
57
-
58
-
59
- def update(self, dt: float):
60
- particles_to_remove = []
61
- for particle in self.particles:
62
- particle.update(dt)
63
- if particle.dead:
64
- particles_to_remove.append(particle)
65
- for p in particles_to_remove:
66
- self.particles.remove(p)
67
-
68
- def draw(self, camera) -> bool:
69
- camera.surface.fblits(
70
- [
71
- (
72
- p.surface,
73
- tuple(round(i * self.z_depth) for i in camera.transpose(self.rect).topleft)
74
- ) for p in self.particles
75
- ]
76
- )
77
- return len(self.particles)
File without changes
@@ -1,58 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: batframework
3
- Version: 1.0.8a2
4
- Summary: Pygame framework for making games easier.
5
- Author-email: Turan Baturay <baturayturan@gmail.com>
6
- Project-URL: Homepage, https://github.com/TuranBaturay/batFramework
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.10
11
- Description-Content-Type: text/markdown
12
- Requires-Dist: pygame-ce
13
-
14
- # batFramework
15
-
16
- batFramework is a Python game framework built using Pygame, designed to simplify game development by providing entities, scenes, a scene manager, and various utilities.
17
-
18
- ## Purpose and Overview
19
- The primary objective of batFramework is to streamline game development by utilizing entities and scenes that hold entities. It employs a manager, which inherits from the scene manager, to handle scenes, propagate events, and manage updates and rendering.
20
-
21
- ## Installation and Setup
22
- To install batFramework, you can use pip:
23
- ```pip install batFramework```
24
-
25
-
26
- The only dependency required is pygame-ce.
27
-
28
- ## Usage Instructions
29
- To create a basic app using batFramework, here's an example:
30
-
31
- ```python
32
- import batFramework as bf
33
-
34
- # Initialize the framework
35
- bf.init((1280, 720), window_title="My Amazing Program")
36
-
37
- # Create a manager and a scene
38
- bf.Manager(bf.Scene("main")).run()
39
- ```
40
- In practice, users can inherit bf.Scene to create their own scenes, adding specific behaviors, entities, etc.
41
-
42
- ## Features and Functionalities
43
-
44
- - Scene management for organizing game components
45
- - Cutscene support to facilitate storytelling sequences
46
- - Audio management for music and sound effects with volume control
47
- - Entity, sprite, and animated sprite support
48
- - Utility modules such as time management and easingAnimation
49
-
50
- Users can leverage these functionalities to build games efficiently using batFramework.
51
-
52
- For more detailed usage and examples, please refer to the documentation or codebase.
53
-
54
-
55
- # License
56
- MIT License
57
-
58
-
@@ -1,42 +0,0 @@
1
- batFramework/__init__.py,sha256=MLVXC2ymkO3k8LdCgB6TbahgJfhxk4GKAbmndmEgZS4,2146
2
- batFramework/action.py,sha256=Phk6-q2P-XyV2GVlXPpxyje0due4fIrKnhI1_4anfjI,7600
3
- batFramework/actionContainer.py,sha256=K9dIgG559ckxzRB3t-lpON4dFTcM2mcKZfsf4bhuJ1k,1092
4
- batFramework/animatedSprite.py,sha256=kJPKrTOfkbQu2uYDziIEop1z6-gjBwZxkC1Rxd_vBwE,3992
5
- batFramework/audioManager.py,sha256=5UsDPy4zsDO7Va1y1kM4lSpEJXU95o9F01E-Sts3osg,2546
6
- batFramework/camera.py,sha256=wt4TyWTgQmQElBVeFI7ONzNI75r0FKtB3KmNH00GeFM,4322
7
- batFramework/constants.py,sha256=FSyEYLxdAb3JaXA11sAwZBfAImedASohpFcd_7qnG0I,2075
8
- batFramework/cutscene.py,sha256=5aiIQeWGmvHCb-N3vjmwxhE4dCXv3iZRFHiexSNxCXM,3650
9
- batFramework/cutsceneBlocks.py,sha256=1gmof0jKJ8SqE-RoErm6n1A0JJ4Ang9Q30xEZnW9NaI,5123
10
- batFramework/debugger.py,sha256=gh5kOUmGr4t-BFXA17tImid4nzxUqrhsUhE_JV9srNg,1671
11
- batFramework/dynamicEntity.py,sha256=REIqH0jnfX6yUThoQNkQrsG0390TR6C5la1h2MAioYk,665
12
- batFramework/easing.py,sha256=vGkk7FDPj27X7NCJXALCEyVKDbpXXebWYtMvxkbhOh0,2217
13
- batFramework/entity.py,sha256=Tw4_PIA_sY8fhbj9TjE6wPcDTrZZX_Tj7l8oKquqe8U,3178
14
- batFramework/manager.py,sha256=LdiQVyuPQE23jwO4EjR4zqDymxtRmthUJ7VE7RIEDpU,1583
15
- batFramework/particles.py,sha256=PX8zSqOS1gyDloGAz3fAlrto51lWMUpBXDIM152EYWc,2172
16
- batFramework/scene.py,sha256=KM1e53ZfPvuJoSGQZaEl_IouWRYCbFq0QOYTuXYCr-E,7324
17
- batFramework/sceneManager.py,sha256=sFkQbfMuR19M4duvCf0SOxSY7MkMrkmiiKh72-tC1nI,5743
18
- batFramework/stateMachine.py,sha256=_er9_dcm6MLmlTjXTVm175eqZ9puaKb31PFmNPRhcSU,1338
19
- batFramework/time.py,sha256=iGV9mxUFrdXsvm4fJ1faX-VYNsOH7DX2N_aXsDRHhmM,2403
20
- batFramework/transition.py,sha256=wmL1Mgg_xopzeDbEPJyAmllLB2BCRJZtuMOR7Mez480,4873
21
- batFramework/transitionManager.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- batFramework/triggerZone.py,sha256=ikOOlJT1KIND0MO2xiilCHuKlb1eQhkCMEhZTi1btsI,586
23
- batFramework/utils.py,sha256=EUB3bMldWTYFVZxcJk5_7XAWcEz080P7PT5ZtkO5TAQ,6164
24
- batFramework/gui/__init__.py,sha256=azu5HpC8Q9kupythU5GN5blt7K9oH55oXlOeXsIw1Mw,391
25
- batFramework/gui/button.py,sha256=05RMQ20P5npgU9QmiT8v6abJhnhjqRgYbpZGaQXr6Bg,2703
26
- batFramework/gui/constraints.py,sha256=pUTNwJqI2Tu57l8ZeQXVXg3b5F5t3aR4Us-CD5qXwnM,7544
27
- batFramework/gui/container.py,sha256=XAkPZ0BOVXxzxWP5mKDF_MjYPPPAmUBY-J5zIadO0wQ,1480
28
- batFramework/gui/debugger.py,sha256=JORHcSYQQCZ0tDzjnNQvDSOOjZVwEQLeqlr8e6xk2RI,1379
29
- batFramework/gui/frame.py,sha256=zjHwbQT1fpRuvNgfBGZhMO_GdMEWqExa5dNlN9kUnUM,514
30
- batFramework/gui/image.py,sha256=goOcPntsJeTb3LR7avzi4cXfYHwyGb0KXYttbCiE6fA,777
31
- batFramework/gui/indicator.py,sha256=OgqDFsi2HCfbSzVjHkHO_shmo4q4ro3wfd0LWSLTJeQ,957
32
- batFramework/gui/interactiveWidget.py,sha256=rRElxI1eFkvOeTfTaA6f8kVTOswOD-DFLAJDUCAI_Yk,641
33
- batFramework/gui/label.py,sha256=EO1J5zPVe1skHz-KVqXKBZVKug8UVJUCXyHnvdRDuig,3586
34
- batFramework/gui/layout.py,sha256=HyVhYTy1AQacALg6XMY5aX5lj7WY__HCCh8sTSBXwgI,3210
35
- batFramework/gui/root.py,sha256=mhlu8ohqq8N-8q__ugv_tGRgPv-1jIHXBFezMFZ4mUM,1763
36
- batFramework/gui/shape.py,sha256=CYaD0BdCiuGJO_tS2pALfKPlNGaGRNPzvy-Lk08_R8g,2490
37
- batFramework/gui/toggle.py,sha256=jAeEyQXA893gDBUmjN7aoGgfsVln5RTODpSFB4LxwTY,2020
38
- batFramework/gui/widget.py,sha256=1PkxThmet8nI5rvSDE6-iPtD_DsZkk-OxriZHbBZaFc,10509
39
- batframework-1.0.8a2.dist-info/METADATA,sha256=YnyIVG7YvAIqBiqWVbeQ6h4tWUT7VHAHUr_Is1uQyJw,1980
40
- batframework-1.0.8a2.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
41
- batframework-1.0.8a2.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
42
- batframework-1.0.8a2.dist-info/RECORD,,