batframework 1.0.9a11__py3-none-any.whl → 1.0.10__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 +53 -76
- batFramework/action.py +99 -126
- batFramework/actionContainer.py +9 -53
- batFramework/animatedSprite.py +114 -56
- batFramework/audioManager.py +36 -82
- batFramework/camera.py +69 -263
- batFramework/constants.py +53 -29
- batFramework/cutscene.py +109 -243
- batFramework/cutsceneBlocks.py +176 -0
- batFramework/debugger.py +48 -0
- batFramework/dynamicEntity.py +9 -16
- batFramework/easing.py +71 -0
- batFramework/entity.py +85 -92
- batFramework/gui/__init__.py +3 -14
- batFramework/gui/button.py +78 -12
- batFramework/gui/constraints.py +204 -0
- batFramework/gui/container.py +31 -188
- batFramework/gui/debugger.py +43 -126
- batFramework/gui/frame.py +19 -0
- batFramework/gui/image.py +20 -55
- batFramework/gui/indicator.py +22 -95
- batFramework/gui/interactiveWidget.py +12 -229
- batFramework/gui/label.py +77 -311
- batFramework/gui/layout.py +66 -414
- batFramework/gui/root.py +35 -203
- batFramework/gui/shape.py +57 -247
- batFramework/gui/toggle.py +48 -114
- batFramework/gui/widget.py +243 -457
- batFramework/manager.py +29 -113
- batFramework/particles.py +77 -0
- batFramework/scene.py +217 -22
- batFramework/sceneManager.py +129 -161
- batFramework/stateMachine.py +8 -11
- batFramework/time.py +75 -0
- batFramework/transition.py +124 -129
- batFramework/transitionManager.py +0 -0
- batFramework/triggerZone.py +4 -4
- batFramework/utils.py +144 -266
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/METADATA +24 -17
- batframework-1.0.10.dist-info/RECORD +43 -0
- batFramework/animation.py +0 -77
- batFramework/baseScene.py +0 -240
- batFramework/cutsceneManager.py +0 -34
- batFramework/drawable.py +0 -77
- batFramework/easingController.py +0 -58
- batFramework/enums.py +0 -135
- batFramework/fontManager.py +0 -65
- batFramework/gui/animatedLabel.py +0 -89
- batFramework/gui/clickableWidget.py +0 -244
- batFramework/gui/constraints/__init__.py +0 -1
- batFramework/gui/constraints/constraints.py +0 -980
- batFramework/gui/draggableWidget.py +0 -44
- batFramework/gui/meter.py +0 -96
- batFramework/gui/radioButton.py +0 -35
- batFramework/gui/selector.py +0 -250
- batFramework/gui/slider.py +0 -397
- batFramework/gui/style.py +0 -10
- batFramework/gui/styleManager.py +0 -54
- batFramework/gui/syncedVar.py +0 -49
- batFramework/gui/textInput.py +0 -306
- batFramework/gui/tooltip.py +0 -30
- batFramework/particle.py +0 -118
- batFramework/propertyEaser.py +0 -79
- batFramework/renderGroup.py +0 -34
- batFramework/resourceManager.py +0 -130
- batFramework/sceneLayer.py +0 -138
- batFramework/scrollingSprite.py +0 -115
- batFramework/sprite.py +0 -51
- batFramework/templates/__init__.py +0 -1
- batFramework/templates/controller.py +0 -97
- batFramework/tileset.py +0 -46
- batFramework/timeManager.py +0 -213
- batframework-1.0.9a11.dist-info/RECORD +0 -67
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/LICENSE +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/top_level.txt +0 -0
batFramework/transition.py
CHANGED
@@ -1,162 +1,157 @@
|
|
1
|
-
import batFramework as bf
|
2
|
-
from typing import Self,Callable,Any
|
3
1
|
import pygame
|
4
|
-
|
5
|
-
"""
|
6
|
-
Both surfaces to transition need to be the same size
|
7
|
-
|
8
|
-
"""
|
2
|
+
import batFramework as bf
|
9
3
|
|
10
4
|
|
11
|
-
class
|
5
|
+
class BaseTransition:
|
12
6
|
def __init__(
|
13
|
-
self,
|
7
|
+
self,
|
8
|
+
source_surf: pygame.Surface,
|
9
|
+
dest_surf: pygame.Surface,
|
10
|
+
duration=100,
|
11
|
+
**kwargs,
|
14
12
|
) -> None:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
""
|
19
|
-
self.
|
20
|
-
self.
|
21
|
-
|
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
|
13
|
+
self.source = source_surf
|
14
|
+
self.dest = dest_surf
|
15
|
+
self.ended = False
|
16
|
+
self.source_scene_name = ""
|
17
|
+
self.dest_scene_name = ""
|
18
|
+
self.duration = duration
|
19
|
+
self.index = 0
|
33
20
|
|
34
|
-
def
|
35
|
-
self.
|
21
|
+
def set_scene_index(self,index):
|
22
|
+
self.index = index
|
36
23
|
|
37
|
-
def
|
38
|
-
|
39
|
-
return
|
40
|
-
if self.duration: # start the transition
|
41
|
-
self.controller.start()
|
42
|
-
return
|
24
|
+
def set_source_name(self, name):
|
25
|
+
self.source_scene_name = name
|
43
26
|
|
44
|
-
|
45
|
-
self.
|
46
|
-
self.controller.end()
|
47
|
-
self.update(1)# to prevent weird behaviour, update once with progression at max value
|
48
|
-
self.end()
|
27
|
+
def set_dest_name(self, name):
|
28
|
+
self.dest_scene_name = name
|
49
29
|
|
50
|
-
def update(self,
|
30
|
+
def update(self, dt):
|
51
31
|
pass
|
52
32
|
|
53
|
-
def
|
54
|
-
self.controller.stop()
|
55
|
-
self.is_over = True
|
56
|
-
|
57
|
-
def draw(self, surface: pygame.Surface) -> None:
|
33
|
+
def draw(self, surface):
|
58
34
|
pass
|
59
35
|
|
60
|
-
def
|
61
|
-
|
36
|
+
def has_ended(self):
|
37
|
+
return False
|
62
38
|
|
39
|
+
def set_ended(self, val):
|
40
|
+
self.ended = val
|
63
41
|
|
64
42
|
|
65
|
-
class
|
66
|
-
def __init__(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
43
|
+
class FadeColorTransition(BaseTransition):
|
44
|
+
def __init__(
|
45
|
+
self,
|
46
|
+
source_surf,
|
47
|
+
dest_surf,
|
48
|
+
duration=600,
|
49
|
+
color_duration=200,
|
50
|
+
color=bf.color.CLOUD_WHITE,
|
51
|
+
**kwargs,
|
52
|
+
) -> None:
|
53
|
+
super().__init__(source_surf, dest_surf, duration)
|
54
|
+
self.target_time = duration * 2 + color_duration
|
55
|
+
self.color_surf = pygame.Surface((source_surf.get_rect().size)).convert_alpha()
|
56
|
+
self.color_surf.fill(color)
|
57
|
+
self.ease_out = bf.EasingAnimation(
|
58
|
+
easing_function=bf.Easing.EASE_IN,
|
59
|
+
duration=(duration-color_duration)//2,
|
60
|
+
update_callback = lambda x: self.color_surf.set_alpha(int(255 - (255 * x))),
|
61
|
+
end_callback=lambda: self.set_ended(True))
|
62
|
+
|
63
|
+
self.color_timer = bf.Timer(
|
64
|
+
duration=color_duration,
|
65
|
+
end_callback=lambda: self.set_state("out"))
|
66
|
+
self.ease_in = bf.EasingAnimation(
|
67
|
+
easing_function=bf.Easing.EASE_IN,
|
68
|
+
duration=(duration-color_duration)//2,
|
69
|
+
update_callback=lambda x: self.color_surf.set_alpha(int(255 * x)),
|
70
|
+
# update_callback=lambda x: print(x),
|
71
|
+
end_callback=lambda: self.set_state("color"))
|
72
|
+
self.state = None
|
73
|
+
|
74
|
+
self.state = "in"
|
75
|
+
self.ease_in.start()
|
76
|
+
|
77
|
+
def set_state(self, state: str):
|
78
|
+
self.state = state
|
79
|
+
if state == "in":
|
80
|
+
self.ease_in.start()
|
81
|
+
elif state == "color":
|
82
|
+
self.color_timer.start()
|
83
|
+
elif state == "out":
|
84
|
+
self.ease_out.start()
|
85
|
+
|
86
|
+
def has_ended(self):
|
87
|
+
return self.ended
|
88
|
+
|
89
|
+
def set_ended(self, val):
|
90
|
+
super().set_ended(val)
|
76
91
|
|
77
92
|
def draw(self, surface):
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
self.color_surf.set_alpha(255*v)
|
82
|
-
surface.blit(self.source)
|
83
|
-
surface.blit(self.color_surf)
|
93
|
+
if self.state != "color":
|
94
|
+
surface.blit(self.source if self.state == "in" else self.dest, (0, 0))
|
95
|
+
surface.blit(self.color_surf, (0, 0))
|
84
96
|
|
85
|
-
elif v < self.color_end:
|
86
|
-
self.color_surf.set_alpha(255)
|
87
|
-
surface.blit(self.color_surf)
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
98
|
+
class FadeTransition(BaseTransition):
|
99
|
+
def __init__(self, source_surf, dest_surf, duration=500) -> None:
|
100
|
+
super().__init__(source_surf, dest_surf)
|
101
|
+
self.anim = bf.EasingAnimation(None,bf.Easing.EASE_IN_OUT,duration,self.update_surface,lambda : self.set_ended(True))
|
102
|
+
self.anim.start()
|
94
103
|
|
95
|
-
|
96
|
-
|
97
|
-
self.dest.set_alpha(255)
|
98
|
-
return super().end()
|
104
|
+
def update_surface(self,progress):
|
105
|
+
self.source.set_alpha(int(255 - (255 * progress)))
|
106
|
+
self.dest.set_alpha(int(255 * progress))
|
99
107
|
|
100
|
-
def
|
101
|
-
|
108
|
+
def has_ended(self):
|
109
|
+
return self.ended
|
102
110
|
|
103
111
|
def draw(self, surface):
|
104
|
-
dest_alpha = 255 * self.controller.get_value()
|
105
|
-
self.dest.set_alpha(dest_alpha)
|
106
112
|
surface.blit(self.source, (0, 0))
|
107
113
|
surface.blit(self.dest, (0, 0))
|
108
114
|
|
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
115
|
|
136
|
-
|
137
|
-
|
138
|
-
|
116
|
+
class SlideTransition(BaseTransition):
|
117
|
+
def __init__(
|
118
|
+
self,
|
119
|
+
source_surf,
|
120
|
+
dest_surf,
|
121
|
+
duration=1000,
|
122
|
+
source_alignment: bf.Alignment = bf.Alignment.BOTTOM,
|
123
|
+
easing: bf.Easing = bf.Easing.EASE_IN_OUT,
|
124
|
+
**kwargs,
|
125
|
+
) -> None:
|
126
|
+
super().__init__(source_surf, dest_surf, duration)
|
127
|
+
self.offset = pygame.Vector2(0, 0)
|
128
|
+
if source_alignment in [bf.Alignment.TOP, bf.Alignment.BOTTOM]:
|
129
|
+
self.offset.y = bf.const.RESOLUTION[1]
|
130
|
+
if source_alignment == bf.Alignment.TOP:
|
131
|
+
self.offset.y *= -1
|
132
|
+
elif source_alignment in [bf.Alignment.LEFT, bf.Alignment.RIGHT]:
|
133
|
+
self.offset.x = bf.const.RESOLUTION[0]
|
134
|
+
if source_alignment == bf.Alignment.LEFT:
|
135
|
+
self.offset.x *= -1
|
136
|
+
else:
|
137
|
+
self.offset.x = -bf.const.RESOLUTION[0]
|
138
|
+
print(
|
139
|
+
f"Unsupported Alignment : {source_alignment.value}, set to default : {bf.Alignment.LEFT.value} "
|
140
|
+
)
|
141
|
+
self.anim = bf.EasingAnimation(
|
142
|
+
easing_function=easing,
|
143
|
+
duration=duration,
|
144
|
+
update_callback =lambda x: self.update_offset(self.offset.lerp((0, 0), x)),
|
145
|
+
end_callback =lambda: self.set_ended(True),
|
139
146
|
)
|
140
|
-
|
141
|
-
mask.to_surface(surface=surface, setsurface=self.dest, unsetsurface=self.source)
|
147
|
+
self.anim.start()
|
142
148
|
|
149
|
+
def update_offset(self, vec):
|
150
|
+
self.offset.update(vec)
|
143
151
|
|
144
|
-
|
145
|
-
|
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()
|
152
|
+
def has_ended(self):
|
153
|
+
return self.ended
|
151
154
|
|
152
155
|
def draw(self, surface):
|
153
|
-
|
154
|
-
|
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
|
-
|
156
|
+
surface.blit(self.source, (0, 0))
|
157
|
+
surface.blit(self.dest, self.offset)
|
File without changes
|
batFramework/triggerZone.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import batFramework as bf
|
2
|
-
|
2
|
+
|
3
3
|
|
4
4
|
class TriggerZone(bf.Entity):
|
5
|
-
def __init__(self, size, trigger, callback
|
5
|
+
def __init__(self, size, trigger, callback, active=True) -> None:
|
6
6
|
super().__init__(size, True)
|
7
|
-
self.set_debug_color(bf.color.
|
7
|
+
self.set_debug_color(bf.color.RIVER_BLUE)
|
8
8
|
self.active = active
|
9
9
|
self.callback = callback
|
10
10
|
self.trigger = trigger
|
@@ -13,7 +13,7 @@ class TriggerZone(bf.Entity):
|
|
13
13
|
self.trigger = trigger
|
14
14
|
return self
|
15
15
|
|
16
|
-
def set_callback(self, callback
|
16
|
+
def set_callback(self, callback):
|
17
17
|
self.callback = callback
|
18
18
|
return self
|
19
19
|
|