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.
- batFramework/__init__.py +3 -11
- 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 -244
- 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 -206
- 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 -429
- 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.9a11.dist-info → batframework-1.0.9a13.dist-info}/LICENSE +20 -20
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/METADATA +24 -17
- batframework-1.0.9a13.dist-info/RECORD +72 -0
- batframework-1.0.9a11.dist-info/RECORD +0 -67
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/top_level.txt +0 -0
batFramework/cutsceneManager.py
CHANGED
@@ -1,34 +1,34 @@
|
|
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
|
-
self.is_playing : bool = False
|
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
|
-
|
25
|
-
self.current_cutscene = cutscene
|
26
|
-
cutscene.start()
|
27
|
-
self.is_playing = True
|
28
|
-
|
29
|
-
def update(self,dt):
|
30
|
-
if self.current_cutscene:
|
31
|
-
self.current_cutscene.update(dt)
|
32
|
-
if self.current_cutscene.is_over:
|
33
|
-
self.current_cutscene = None
|
34
|
-
self.is_playing = False
|
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
|
+
self.is_playing : bool = False
|
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
|
+
|
25
|
+
self.current_cutscene = cutscene
|
26
|
+
cutscene.start()
|
27
|
+
self.is_playing = True
|
28
|
+
|
29
|
+
def update(self,dt):
|
30
|
+
if self.current_cutscene:
|
31
|
+
self.current_cutscene.update(dt)
|
32
|
+
if self.current_cutscene.is_over:
|
33
|
+
self.current_cutscene = None
|
34
|
+
self.is_playing = False
|
batFramework/drawable.py
CHANGED
@@ -1,77 +1,107 @@
|
|
1
|
-
from typing import Any, Self
|
2
|
-
import pygame
|
3
|
-
import batFramework as bf
|
4
|
-
from .entity import Entity
|
5
|
-
|
6
|
-
|
7
|
-
class Drawable(Entity):
|
8
|
-
"""
|
9
|
-
Basic entity class
|
10
|
-
"""
|
11
|
-
|
12
|
-
def __init__(
|
13
|
-
self,
|
14
|
-
size: None | tuple[int|float] = None,
|
15
|
-
surface_flags: int = 0,
|
16
|
-
convert_alpha: bool = False,
|
17
|
-
*args,
|
18
|
-
**kwargs,
|
19
|
-
) -> None:
|
20
|
-
super().__init__()
|
21
|
-
self.visible: bool = True
|
22
|
-
self.render_order: int = 0
|
23
|
-
if size is not None:
|
24
|
-
self.rect.size = size
|
25
|
-
self.convert_alpha: bool = convert_alpha
|
26
|
-
self.surface_flags: int = surface_flags
|
27
|
-
self.blit_flags: int = 0
|
28
|
-
self.drawn_by_group : bool = False # flag for render group
|
29
|
-
self.surface: pygame.Surface = pygame.Surface(self.rect.size, surface_flags)
|
30
|
-
if convert_alpha:
|
31
|
-
self.surface = self.surface.convert_alpha()
|
32
|
-
self.surface.fill((0, 0, 0, 0))
|
33
|
-
|
34
|
-
def set_alpha(self, alpha: int) -> Self:
|
35
|
-
self.surface.set_alpha(min(max(0, alpha), 255))
|
36
|
-
return self
|
37
|
-
|
38
|
-
def get_alpha(self) -> int:
|
39
|
-
return self.surface.get_alpha()
|
40
|
-
|
41
|
-
def set_surface_flags(self, surface_flags: int) -> Self:
|
42
|
-
self.surface_flags = surface_flags
|
43
|
-
return self
|
44
|
-
|
45
|
-
def set_convert_alpha(self, value: bool) -> Self:
|
46
|
-
self.convert_alpha = value
|
47
|
-
return self
|
48
|
-
|
49
|
-
def set_blit_flags(self, blit_flags: int) -> Self:
|
50
|
-
self.blit_flags = blit_flags
|
51
|
-
return self
|
52
|
-
|
53
|
-
def get_debug_outlines(self):
|
54
|
-
if self.visible:
|
55
|
-
yield (self.rect, self.debug_color)
|
56
|
-
|
57
|
-
def set_render_order(self, render_order: int) -> Self:
|
58
|
-
self.render_order = render_order
|
59
|
-
if self.parent_layer:
|
60
|
-
self.parent_layer.update_draw_order()
|
61
|
-
return self
|
62
|
-
|
63
|
-
def set_visible(self, value: bool) -> Self:
|
64
|
-
self.visible = value
|
65
|
-
return self
|
66
|
-
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if not self.
|
72
|
-
return
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
from typing import Any, Self
|
2
|
+
import pygame
|
3
|
+
import batFramework as bf
|
4
|
+
from .entity import Entity
|
5
|
+
|
6
|
+
|
7
|
+
class Drawable(Entity):
|
8
|
+
"""
|
9
|
+
Basic entity class
|
10
|
+
"""
|
11
|
+
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
size: None | tuple[int|float] = None,
|
15
|
+
surface_flags: int = 0,
|
16
|
+
convert_alpha: bool = False,
|
17
|
+
*args,
|
18
|
+
**kwargs,
|
19
|
+
) -> None:
|
20
|
+
super().__init__()
|
21
|
+
self.visible: bool = True
|
22
|
+
self.render_order: int = 0
|
23
|
+
if size is not None:
|
24
|
+
self.rect.size = size
|
25
|
+
self.convert_alpha: bool = convert_alpha
|
26
|
+
self.surface_flags: int = surface_flags
|
27
|
+
self.blit_flags: int = 0
|
28
|
+
self.drawn_by_group : bool = False # flag for render group
|
29
|
+
self.surface: pygame.Surface = pygame.Surface(self.rect.size, surface_flags)
|
30
|
+
if convert_alpha:
|
31
|
+
self.surface = self.surface.convert_alpha()
|
32
|
+
self.surface.fill((0, 0, 0, 0))
|
33
|
+
|
34
|
+
def set_alpha(self, alpha: int) -> Self:
|
35
|
+
self.surface.set_alpha(min(max(0, alpha), 255))
|
36
|
+
return self
|
37
|
+
|
38
|
+
def get_alpha(self) -> int:
|
39
|
+
return self.surface.get_alpha()
|
40
|
+
|
41
|
+
def set_surface_flags(self, surface_flags: int) -> Self:
|
42
|
+
self.surface_flags = surface_flags
|
43
|
+
return self
|
44
|
+
|
45
|
+
def set_convert_alpha(self, value: bool) -> Self:
|
46
|
+
self.convert_alpha = value
|
47
|
+
return self
|
48
|
+
|
49
|
+
def set_blit_flags(self, blit_flags: int) -> Self:
|
50
|
+
self.blit_flags = blit_flags
|
51
|
+
return self
|
52
|
+
|
53
|
+
def get_debug_outlines(self):
|
54
|
+
if self.visible:
|
55
|
+
yield (self.rect, self.debug_color)
|
56
|
+
|
57
|
+
def set_render_order(self, render_order: int) -> Self:
|
58
|
+
self.render_order = render_order
|
59
|
+
if self.parent_layer:
|
60
|
+
self.parent_layer.update_draw_order()
|
61
|
+
return self
|
62
|
+
|
63
|
+
def set_visible(self, value: bool) -> Self:
|
64
|
+
self.visible = value
|
65
|
+
return self
|
66
|
+
|
67
|
+
def get_mask(self)->pygame.Mask:
|
68
|
+
return pygame.mask.from_surface(self.surface)
|
69
|
+
|
70
|
+
def mask_collide_point(self,point)->bool:
|
71
|
+
if not self.rect.collidepoint(point):
|
72
|
+
return False
|
73
|
+
mask = pygame.mask.from_surface(self.surface)
|
74
|
+
x = point[0]- self.rect.x
|
75
|
+
y = point[1] - self.rect.y
|
76
|
+
return mask.get_at((x,y))==1
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
def set_size(self, size: tuple[float, float]) -> Self:
|
82
|
+
"""
|
83
|
+
Will erase surface data and create new empty surface
|
84
|
+
"""
|
85
|
+
if size == self.rect.size:
|
86
|
+
return self
|
87
|
+
self.rect.size = size
|
88
|
+
self.surface = pygame.Surface(
|
89
|
+
(int(self.rect.w), int(self.rect.h)), self.surface_flags
|
90
|
+
)
|
91
|
+
if self.convert_alpha:
|
92
|
+
self.surface = self.surface.convert_alpha()
|
93
|
+
self.surface.fill((0, 0, 0, 0 if self.convert_alpha else 255))
|
94
|
+
|
95
|
+
return self
|
96
|
+
|
97
|
+
def draw(self, camera: bf.Camera) -> None:
|
98
|
+
"""
|
99
|
+
Draw the entity onto the camera surface
|
100
|
+
"""
|
101
|
+
if not self.visible or self.drawn_by_group or not camera.world_rect.colliderect(self.rect) or self.surface.get_alpha() == 0:
|
102
|
+
return
|
103
|
+
camera.surface.blit(
|
104
|
+
self.surface,
|
105
|
+
camera.world_to_screen(self.rect),
|
106
|
+
special_flags=self.blit_flags,
|
107
|
+
)
|
batFramework/dynamicEntity.py
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
import pygame
|
2
|
-
import batFramework as bf
|
3
|
-
from typing import Self
|
4
|
-
|
5
|
-
|
6
|
-
class DynamicEntity(bf.Entity):
|
7
|
-
def __init__(
|
8
|
-
self,
|
9
|
-
*args,**kwargs
|
10
|
-
) -> None:
|
11
|
-
super().__init__(*args,**kwargs)
|
12
|
-
self.velocity = pygame.math.Vector2(0, 0)
|
13
|
-
self.ignore_collisions : bool = False
|
14
|
-
|
15
|
-
def on_collideX(self, collider: "DynamicEntity"):
|
16
|
-
"""
|
17
|
-
Return true if collision
|
18
|
-
"""
|
19
|
-
return False
|
20
|
-
|
21
|
-
def on_collideY(self, collider: "DynamicEntity"):
|
22
|
-
"""
|
23
|
-
Return true if collision
|
24
|
-
"""
|
25
|
-
return False
|
26
|
-
|
27
|
-
def move_by_velocity(self, dt) -> None:
|
28
|
-
self.set_position(
|
29
|
-
self.rect.x + self.velocity.x * dt, self.rect.y + self.velocity.y * dt
|
30
|
-
)
|
1
|
+
import pygame
|
2
|
+
import batFramework as bf
|
3
|
+
from typing import Self
|
4
|
+
|
5
|
+
|
6
|
+
class DynamicEntity(bf.Entity):
|
7
|
+
def __init__(
|
8
|
+
self,
|
9
|
+
*args,**kwargs
|
10
|
+
) -> None:
|
11
|
+
super().__init__(*args,**kwargs)
|
12
|
+
self.velocity = pygame.math.Vector2(0, 0)
|
13
|
+
self.ignore_collisions : bool = False
|
14
|
+
|
15
|
+
def on_collideX(self, collider: "DynamicEntity"):
|
16
|
+
"""
|
17
|
+
Return true if collision
|
18
|
+
"""
|
19
|
+
return False
|
20
|
+
|
21
|
+
def on_collideY(self, collider: "DynamicEntity"):
|
22
|
+
"""
|
23
|
+
Return true if collision
|
24
|
+
"""
|
25
|
+
return False
|
26
|
+
|
27
|
+
def move_by_velocity(self, dt) -> None:
|
28
|
+
self.set_position(
|
29
|
+
self.rect.x + self.velocity.x * dt, self.rect.y + self.velocity.y * dt
|
30
|
+
)
|
batFramework/easingController.py
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
import pygame
|
2
|
-
import batFramework as bf
|
3
|
-
from functools import lru_cache
|
4
|
-
from typing import Callable,Any
|
5
|
-
|
6
|
-
|
7
|
-
@lru_cache(maxsize=None)
|
8
|
-
def process_value(progress: float, p0: float, p1: float, p2: float, p3: float) -> float:
|
9
|
-
if p0 == 0 and p1 == 0 and p2 == 1 and p3 == 1: # Linear easing control points
|
10
|
-
return progress
|
11
|
-
t = progress
|
12
|
-
t_inv = 1.0 - t
|
13
|
-
t2 = t * t
|
14
|
-
t3 = t * t2
|
15
|
-
t_inv2 = t_inv * t_inv
|
16
|
-
return 3 * t_inv2 * t * p1 + 3 * t_inv * t2 * p3 + t3
|
17
|
-
|
18
|
-
|
19
|
-
class EasingController(bf.Timer):
|
20
|
-
def __init__(
|
21
|
-
self,
|
22
|
-
duration: float = 1,
|
23
|
-
easing: bf.easing = bf.easing.LINEAR,
|
24
|
-
update_callback=None,
|
25
|
-
end_callback: Callable[[], Any] = None,
|
26
|
-
loop: int = 0,
|
27
|
-
register:str="global"
|
28
|
-
) -> None:
|
29
|
-
self.easing_function = easing
|
30
|
-
self.update_callback: Callable[[float], Any] = update_callback
|
31
|
-
self.value: float = 0.0
|
32
|
-
super().__init__(duration, end_callback, loop, register)
|
33
|
-
|
34
|
-
def get_value(self) -> float:
|
35
|
-
return self.value
|
36
|
-
|
37
|
-
def start(self, force: bool = False):
|
38
|
-
super().start(force)
|
39
|
-
self.value = 0
|
40
|
-
|
41
|
-
def update(self, dt: float) -> None:
|
42
|
-
if self.get_progression() == 1:
|
43
|
-
return
|
44
|
-
super().update(dt)
|
45
|
-
if self.get_progression() == 0:
|
46
|
-
return
|
47
|
-
if self.easing_function == bf.easing.LINEAR: # avoid calculating if linear (just use progression as is)
|
48
|
-
self.value = self.get_progression()
|
49
|
-
else:
|
50
|
-
self.value = process_value(self.get_progression(), *self.easing_function.control_points)
|
51
|
-
|
52
|
-
if self.update_callback:
|
53
|
-
self.update_callback(self.value)
|
54
|
-
|
55
|
-
def end(self):
|
56
|
-
if self.update_callback:
|
57
|
-
self.update_callback(1)
|
58
|
-
super().end()
|
1
|
+
import pygame
|
2
|
+
import batFramework as bf
|
3
|
+
from functools import lru_cache
|
4
|
+
from typing import Callable,Any
|
5
|
+
|
6
|
+
|
7
|
+
@lru_cache(maxsize=None)
|
8
|
+
def process_value(progress: float, p0: float, p1: float, p2: float, p3: float) -> float:
|
9
|
+
if p0 == 0 and p1 == 0 and p2 == 1 and p3 == 1: # Linear easing control points
|
10
|
+
return progress
|
11
|
+
t = progress
|
12
|
+
t_inv = 1.0 - t
|
13
|
+
t2 = t * t
|
14
|
+
t3 = t * t2
|
15
|
+
t_inv2 = t_inv * t_inv
|
16
|
+
return 3 * t_inv2 * t * p1 + 3 * t_inv * t2 * p3 + t3
|
17
|
+
|
18
|
+
|
19
|
+
class EasingController(bf.Timer):
|
20
|
+
def __init__(
|
21
|
+
self,
|
22
|
+
duration: float = 1,
|
23
|
+
easing: bf.easing = bf.easing.LINEAR,
|
24
|
+
update_callback=None,
|
25
|
+
end_callback: Callable[[], Any] = None,
|
26
|
+
loop: int = 0,
|
27
|
+
register:str="global"
|
28
|
+
) -> None:
|
29
|
+
self.easing_function = easing
|
30
|
+
self.update_callback: Callable[[float], Any] = update_callback
|
31
|
+
self.value: float = 0.0
|
32
|
+
super().__init__(duration, end_callback, loop, register)
|
33
|
+
|
34
|
+
def get_value(self) -> float:
|
35
|
+
return self.value
|
36
|
+
|
37
|
+
def start(self, force: bool = False):
|
38
|
+
super().start(force)
|
39
|
+
self.value = 0
|
40
|
+
|
41
|
+
def update(self, dt: float) -> None:
|
42
|
+
if self.get_progression() == 1:
|
43
|
+
return
|
44
|
+
super().update(dt)
|
45
|
+
if self.get_progression() == 0:
|
46
|
+
return
|
47
|
+
if self.easing_function == bf.easing.LINEAR: # avoid calculating if linear (just use progression as is)
|
48
|
+
self.value = self.get_progression()
|
49
|
+
else:
|
50
|
+
self.value = process_value(self.get_progression(), *self.easing_function.control_points)
|
51
|
+
|
52
|
+
if self.update_callback:
|
53
|
+
self.update_callback(self.value)
|
54
|
+
|
55
|
+
def end(self):
|
56
|
+
if self.update_callback:
|
57
|
+
self.update_callback(1)
|
58
|
+
super().end()
|