batframework 1.0.9a10__py3-none-any.whl → 1.0.9a12__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 +2 -0
- batFramework/action.py +280 -279
- batFramework/actionContainer.py +105 -82
- batFramework/animatedSprite.py +80 -58
- batFramework/animation.py +91 -77
- batFramework/audioManager.py +156 -131
- batFramework/baseScene.py +249 -240
- batFramework/camera.py +245 -317
- batFramework/constants.py +57 -51
- batFramework/cutscene.py +239 -253
- batFramework/cutsceneManager.py +34 -34
- batFramework/drawable.py +107 -77
- batFramework/dynamicEntity.py +30 -30
- batFramework/easingController.py +58 -58
- batFramework/entity.py +130 -130
- batFramework/enums.py +171 -135
- batFramework/fontManager.py +65 -65
- batFramework/gui/__init__.py +28 -25
- batFramework/gui/animatedLabel.py +90 -89
- batFramework/gui/button.py +17 -17
- batFramework/gui/clickableWidget.py +244 -245
- batFramework/gui/collapseContainer.py +98 -0
- batFramework/gui/constraints/__init__.py +1 -1
- batFramework/gui/constraints/constraints.py +1066 -980
- batFramework/gui/container.py +220 -201
- batFramework/gui/debugger.py +140 -130
- batFramework/gui/draggableWidget.py +63 -44
- batFramework/gui/image.py +61 -58
- batFramework/gui/indicator.py +116 -113
- batFramework/gui/interactiveWidget.py +243 -239
- batFramework/gui/label.py +147 -344
- batFramework/gui/layout.py +442 -426
- batFramework/gui/meter.py +155 -96
- batFramework/gui/radioButton.py +43 -35
- batFramework/gui/root.py +228 -228
- batFramework/gui/scrollingContainer.py +282 -0
- batFramework/gui/selector.py +232 -250
- batFramework/gui/shape.py +286 -276
- batFramework/gui/slider.py +353 -397
- batFramework/gui/style.py +10 -10
- batFramework/gui/styleManager.py +49 -54
- batFramework/gui/syncedVar.py +43 -49
- batFramework/gui/textInput.py +331 -306
- batFramework/gui/textWidget.py +308 -0
- batFramework/gui/toggle.py +140 -128
- batFramework/gui/tooltip.py +35 -30
- batFramework/gui/widget.py +546 -521
- batFramework/manager.py +131 -134
- batFramework/particle.py +118 -118
- batFramework/propertyEaser.py +79 -79
- batFramework/renderGroup.py +34 -34
- batFramework/resourceManager.py +130 -130
- batFramework/scene.py +31 -31
- batFramework/sceneLayer.py +134 -138
- batFramework/sceneManager.py +200 -197
- batFramework/scrollingSprite.py +115 -115
- batFramework/sprite.py +46 -51
- batFramework/stateMachine.py +49 -54
- batFramework/templates/__init__.py +2 -1
- batFramework/templates/character.py +15 -0
- batFramework/templates/controller.py +158 -97
- batFramework/templates/stateMachine.py +39 -0
- batFramework/tileset.py +46 -46
- batFramework/timeManager.py +213 -213
- batFramework/transition.py +162 -162
- batFramework/triggerZone.py +22 -22
- batFramework/utils.py +306 -306
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/LICENSE +20 -20
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/METADATA +24 -17
- batframework-1.0.9a12.dist-info/RECORD +72 -0
- batframework-1.0.9a10.dist-info/RECORD +0 -67
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/top_level.txt +0 -0
batFramework/transition.py
CHANGED
@@ -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
|
+
|
batFramework/triggerZone.py
CHANGED
@@ -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()
|