batframework 1.0.9a11__py3-none-any.whl → 1.0.9a13__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 (73) hide show
  1. batFramework/__init__.py +3 -11
  2. batFramework/action.py +280 -279
  3. batFramework/actionContainer.py +105 -82
  4. batFramework/animatedSprite.py +80 -58
  5. batFramework/animation.py +91 -77
  6. batFramework/audioManager.py +156 -131
  7. batFramework/baseScene.py +249 -240
  8. batFramework/camera.py +245 -317
  9. batFramework/constants.py +57 -51
  10. batFramework/cutscene.py +239 -253
  11. batFramework/cutsceneManager.py +34 -34
  12. batFramework/drawable.py +107 -77
  13. batFramework/dynamicEntity.py +30 -30
  14. batFramework/easingController.py +58 -58
  15. batFramework/entity.py +130 -130
  16. batFramework/enums.py +171 -135
  17. batFramework/fontManager.py +65 -65
  18. batFramework/gui/__init__.py +28 -25
  19. batFramework/gui/animatedLabel.py +90 -89
  20. batFramework/gui/button.py +17 -17
  21. batFramework/gui/clickableWidget.py +244 -244
  22. batFramework/gui/collapseContainer.py +98 -0
  23. batFramework/gui/constraints/__init__.py +1 -1
  24. batFramework/gui/constraints/constraints.py +1066 -980
  25. batFramework/gui/container.py +220 -206
  26. batFramework/gui/debugger.py +140 -130
  27. batFramework/gui/draggableWidget.py +63 -44
  28. batFramework/gui/image.py +61 -58
  29. batFramework/gui/indicator.py +116 -113
  30. batFramework/gui/interactiveWidget.py +243 -239
  31. batFramework/gui/label.py +147 -344
  32. batFramework/gui/layout.py +442 -429
  33. batFramework/gui/meter.py +155 -96
  34. batFramework/gui/radioButton.py +43 -35
  35. batFramework/gui/root.py +228 -228
  36. batFramework/gui/scrollingContainer.py +282 -0
  37. batFramework/gui/selector.py +232 -250
  38. batFramework/gui/shape.py +286 -276
  39. batFramework/gui/slider.py +353 -397
  40. batFramework/gui/style.py +10 -10
  41. batFramework/gui/styleManager.py +49 -54
  42. batFramework/gui/syncedVar.py +43 -49
  43. batFramework/gui/textInput.py +331 -306
  44. batFramework/gui/textWidget.py +308 -0
  45. batFramework/gui/toggle.py +140 -128
  46. batFramework/gui/tooltip.py +35 -30
  47. batFramework/gui/widget.py +546 -521
  48. batFramework/manager.py +131 -134
  49. batFramework/particle.py +118 -118
  50. batFramework/propertyEaser.py +79 -79
  51. batFramework/renderGroup.py +34 -34
  52. batFramework/resourceManager.py +130 -130
  53. batFramework/scene.py +31 -31
  54. batFramework/sceneLayer.py +134 -138
  55. batFramework/sceneManager.py +200 -197
  56. batFramework/scrollingSprite.py +115 -115
  57. batFramework/sprite.py +46 -51
  58. batFramework/stateMachine.py +49 -54
  59. batFramework/templates/__init__.py +2 -1
  60. batFramework/templates/character.py +15 -0
  61. batFramework/templates/controller.py +158 -97
  62. batFramework/templates/stateMachine.py +39 -0
  63. batFramework/tileset.py +46 -46
  64. batFramework/timeManager.py +213 -213
  65. batFramework/transition.py +162 -162
  66. batFramework/triggerZone.py +22 -22
  67. batFramework/utils.py +306 -306
  68. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/LICENSE +20 -20
  69. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/METADATA +24 -17
  70. batframework-1.0.9a13.dist-info/RECORD +72 -0
  71. batframework-1.0.9a11.dist-info/RECORD +0 -67
  72. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/WHEEL +0 -0
  73. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/top_level.txt +0 -0
@@ -1,162 +1,162 @@
1
- import batFramework as bf
2
- from typing import Self,Callable,Any
3
- import pygame
4
-
5
- """
6
- Both surfaces to transition need to be the same size
7
-
8
- """
9
-
10
-
11
- class Transition:
12
- def __init__(
13
- self, duration: float=1, easing: bf.easing = bf.easing.LINEAR
14
- ) -> None:
15
- """
16
- duration : time in seconds
17
- easing function : controls the progression rate
18
- """
19
- self.duration: float = duration
20
- self.controller = bf.EasingController( # main controller for the transition progression
21
- duration,easing,
22
- update_callback=self.update,end_callback=self.end,
23
- )
24
- self.source: pygame.Surface = None
25
- self.dest: pygame.Surface = None
26
- self.is_over : bool = False # this flag tells the manager the transition is over
27
-
28
- def __repr__(self) -> str:
29
- return f"Transition ({self.__class__},{self.duration})"
30
-
31
- def set_source(self, surface: pygame.Surface) -> None:
32
- self.source = surface
33
-
34
- def set_dest(self, surface: pygame.Surface) -> None:
35
- self.dest = surface
36
-
37
- def start(self):
38
- if self.controller.has_started(): # can't start again while it's in progress
39
- return
40
- if self.duration: # start the transition
41
- self.controller.start()
42
- return
43
-
44
- # if no duration the transition is instantaneous
45
- self.controller.start()
46
- self.controller.end()
47
- self.update(1)# to prevent weird behaviour, update once with progression at max value
48
- self.end()
49
-
50
- def update(self, progression: float) -> None:
51
- pass
52
-
53
- def end(self):
54
- self.controller.stop()
55
- self.is_over = True
56
-
57
- def draw(self, surface: pygame.Surface) -> None:
58
- pass
59
-
60
- def skip(self):
61
- self.end()
62
-
63
-
64
-
65
- class FadeColor(Transition):
66
- def __init__(self,duration:float,color=(0,0,0),color_start:float=0.3,color_end:float=0.7, easing = bf.easing.LINEAR):
67
- super().__init__(duration, easing)
68
- self.color = color
69
- self.color_start = color_start
70
- self.color_end = color_end
71
-
72
- def start(self):
73
- super().start()
74
- self.color_surf = pygame.Surface(self.source.get_size())
75
- self.color_surf.fill(self.color)
76
-
77
- def draw(self, surface):
78
- v = self.controller.get_value()
79
- if v < self.color_start:
80
- v = v/(self.color_start)
81
- self.color_surf.set_alpha(255*v)
82
- surface.blit(self.source)
83
- surface.blit(self.color_surf)
84
-
85
- elif v < self.color_end:
86
- self.color_surf.set_alpha(255)
87
- surface.blit(self.color_surf)
88
-
89
- else:
90
- v = (v-self.color_end)/(1-self.color_end)
91
- surface.blit(self.color_surf)
92
- self.dest.set_alpha(255*v)
93
- surface.blit(self.dest)
94
-
95
- class Fade(Transition):
96
- def end(self):
97
- self.dest.set_alpha(255)
98
- return super().end()
99
-
100
- def start(self):
101
- super().start()
102
-
103
- def draw(self, surface):
104
- dest_alpha = 255 * self.controller.get_value()
105
- self.dest.set_alpha(dest_alpha)
106
- surface.blit(self.source, (0, 0))
107
- surface.blit(self.dest, (0, 0))
108
-
109
- class GlideRight(Transition):
110
- def draw(self, surface):
111
- width = surface.get_width()
112
- source_x = -self.controller.get_value() * width
113
- surface.blit(self.source, (source_x, 0))
114
- surface.blit(self.dest, (width + source_x, 0))
115
-
116
-
117
- class GlideLeft(Transition):
118
- def draw(self, surface):
119
- width = surface.get_width()
120
- source_x = self.controller.get_value() * width
121
- surface.blit(self.source, (source_x, 0))
122
- surface.blit(self.dest, (source_x - width, 0))
123
-
124
-
125
- class CircleOut(Transition):
126
- def start(self):
127
- super().start()
128
- self.circle_surf = self.source.copy()
129
- self.circle_surf.set_colorkey((0, 0, 0))
130
- self.circle_surf.fill((0, 0, 0))
131
- self.surface_width = self.circle_surf.get_width()
132
-
133
- def draw(self, surface):
134
- v = self.controller.get_value()
135
-
136
- radius = self.surface_width * v
137
- pygame.draw.circle(
138
- self.circle_surf, "white", self.circle_surf.get_rect().center, radius
139
- )
140
- mask = pygame.mask.from_surface(self.circle_surf)
141
- mask.to_surface(surface=surface, setsurface=self.dest, unsetsurface=self.source)
142
-
143
-
144
- class CircleIn(Transition):
145
- def start(self):
146
- super().start()
147
- self.circle_surf = self.source.copy()
148
- self.circle_surf.set_colorkey((0, 0, 0))
149
- self.circle_surf.fill((0, 0, 0))
150
- self.surface_width = self.circle_surf.get_width()
151
-
152
- def draw(self, surface):
153
- v = self.controller.get_value()
154
- radius = self.surface_width - (self.surface_width * v)
155
- self.circle_surf.fill((0, 0, 0))
156
- pygame.draw.circle(
157
- self.circle_surf, "white", self.circle_surf.get_rect().center, radius
158
- )
159
- mask = pygame.mask.from_surface(self.circle_surf)
160
- mask.to_surface(surface=surface, setsurface=self.source, unsetsurface=self.dest)
161
-
162
-
1
+ import batFramework as bf
2
+ from typing import Self,Callable,Any
3
+ import pygame
4
+
5
+ """
6
+ Both surfaces to transition need to be the same size
7
+
8
+ """
9
+
10
+
11
+ class Transition:
12
+ def __init__(
13
+ self, duration: float=1, easing: bf.easing = bf.easing.LINEAR
14
+ ) -> None:
15
+ """
16
+ duration : time in seconds
17
+ easing function : controls the progression rate
18
+ """
19
+ self.duration: float = duration
20
+ self.controller = bf.EasingController( # main controller for the transition progression
21
+ duration,easing,
22
+ update_callback=self.update,end_callback=self.end,
23
+ )
24
+ self.source: pygame.Surface = None
25
+ self.dest: pygame.Surface = None
26
+ self.is_over : bool = False # this flag tells the manager the transition is over
27
+
28
+ def __repr__(self) -> str:
29
+ return f"Transition ({self.__class__},{self.duration})"
30
+
31
+ def set_source(self, surface: pygame.Surface) -> None:
32
+ self.source = surface
33
+
34
+ def set_dest(self, surface: pygame.Surface) -> None:
35
+ self.dest = surface
36
+
37
+ def start(self):
38
+ if self.controller.has_started(): # can't start again while it's in progress
39
+ return
40
+ if self.duration: # start the transition
41
+ self.controller.start()
42
+ return
43
+
44
+ # if no duration the transition is instantaneous
45
+ self.controller.start()
46
+ self.controller.end()
47
+ self.update(1)# to prevent weird behaviour, update once with progression at max value
48
+ self.end()
49
+
50
+ def update(self, progression: float) -> None:
51
+ pass
52
+
53
+ def end(self):
54
+ self.controller.stop()
55
+ self.is_over = True
56
+
57
+ def draw(self, surface: pygame.Surface) -> None:
58
+ pass
59
+
60
+ def skip(self):
61
+ self.end()
62
+
63
+
64
+
65
+ class FadeColor(Transition):
66
+ def __init__(self,duration:float,color=(0,0,0),color_start:float=0.3,color_end:float=0.7, easing = bf.easing.LINEAR):
67
+ super().__init__(duration, easing)
68
+ self.color = color
69
+ self.color_start = color_start
70
+ self.color_end = color_end
71
+
72
+ def start(self):
73
+ super().start()
74
+ self.color_surf = pygame.Surface(self.source.get_size())
75
+ self.color_surf.fill(self.color)
76
+
77
+ def draw(self, surface):
78
+ v = self.controller.get_value()
79
+ if v < self.color_start:
80
+ v = v/(self.color_start)
81
+ self.color_surf.set_alpha(255*v)
82
+ surface.blit(self.source)
83
+ surface.blit(self.color_surf)
84
+
85
+ elif v < self.color_end:
86
+ self.color_surf.set_alpha(255)
87
+ surface.blit(self.color_surf)
88
+
89
+ else:
90
+ v = (v-self.color_end)/(1-self.color_end)
91
+ surface.blit(self.color_surf)
92
+ self.dest.set_alpha(255*v)
93
+ surface.blit(self.dest)
94
+
95
+ class Fade(Transition):
96
+ def end(self):
97
+ self.dest.set_alpha(255)
98
+ return super().end()
99
+
100
+ def start(self):
101
+ super().start()
102
+
103
+ def draw(self, surface):
104
+ dest_alpha = 255 * self.controller.get_value()
105
+ self.dest.set_alpha(dest_alpha)
106
+ surface.blit(self.source, (0, 0))
107
+ surface.blit(self.dest, (0, 0))
108
+
109
+ class GlideRight(Transition):
110
+ def draw(self, surface):
111
+ width = surface.get_width()
112
+ source_x = -self.controller.get_value() * width
113
+ surface.blit(self.source, (source_x, 0))
114
+ surface.blit(self.dest, (width + source_x, 0))
115
+
116
+
117
+ class GlideLeft(Transition):
118
+ def draw(self, surface):
119
+ width = surface.get_width()
120
+ source_x = self.controller.get_value() * width
121
+ surface.blit(self.source, (source_x, 0))
122
+ surface.blit(self.dest, (source_x - width, 0))
123
+
124
+
125
+ class CircleOut(Transition):
126
+ def start(self):
127
+ super().start()
128
+ self.circle_surf = self.source.copy()
129
+ self.circle_surf.set_colorkey((0, 0, 0))
130
+ self.circle_surf.fill((0, 0, 0))
131
+ self.surface_width = self.circle_surf.get_width()
132
+
133
+ def draw(self, surface):
134
+ v = self.controller.get_value()
135
+
136
+ radius = self.surface_width * v
137
+ pygame.draw.circle(
138
+ self.circle_surf, "white", self.circle_surf.get_rect().center, radius
139
+ )
140
+ mask = pygame.mask.from_surface(self.circle_surf)
141
+ mask.to_surface(surface=surface, setsurface=self.dest, unsetsurface=self.source)
142
+
143
+
144
+ class CircleIn(Transition):
145
+ def start(self):
146
+ super().start()
147
+ self.circle_surf = self.source.copy()
148
+ self.circle_surf.set_colorkey((0, 0, 0))
149
+ self.circle_surf.fill((0, 0, 0))
150
+ self.surface_width = self.circle_surf.get_width()
151
+
152
+ def draw(self, surface):
153
+ v = self.controller.get_value()
154
+ radius = self.surface_width - (self.surface_width * v)
155
+ self.circle_surf.fill((0, 0, 0))
156
+ pygame.draw.circle(
157
+ self.circle_surf, "white", self.circle_surf.get_rect().center, radius
158
+ )
159
+ mask = pygame.mask.from_surface(self.circle_surf)
160
+ mask.to_surface(surface=surface, setsurface=self.source, unsetsurface=self.dest)
161
+
162
+
@@ -1,22 +1,22 @@
1
- import batFramework as bf
2
- from typing import Callable,Any
3
-
4
- class TriggerZone(bf.Entity):
5
- def __init__(self, size, trigger, callback: Callable[[Any],Any], active=True) -> None:
6
- super().__init__(size, True)
7
- self.set_debug_color(bf.color.RED)
8
- self.active = active
9
- self.callback = callback
10
- self.trigger = trigger
11
-
12
- def set_trigger(self, trigger):
13
- self.trigger = trigger
14
- return self
15
-
16
- def set_callback(self, callback: Callable[[Any],Any]):
17
- self.callback = callback
18
- return self
19
-
20
- def update(self, dt):
21
- if self.active and self.trigger():
22
- self.callback()
1
+ import batFramework as bf
2
+ from typing import Callable,Any
3
+
4
+ class TriggerZone(bf.Entity):
5
+ def __init__(self, size, trigger, callback: Callable[[Any],Any], active=True) -> None:
6
+ super().__init__(size, True)
7
+ self.set_debug_color(bf.color.RED)
8
+ self.active = active
9
+ self.callback = callback
10
+ self.trigger = trigger
11
+
12
+ def set_trigger(self, trigger):
13
+ self.trigger = trigger
14
+ return self
15
+
16
+ def set_callback(self, callback: Callable[[Any],Any]):
17
+ self.callback = callback
18
+ return self
19
+
20
+ def update(self, dt):
21
+ if self.active and self.trigger():
22
+ self.callback()