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.
Files changed (73) hide show
  1. batFramework/__init__.py +2 -0
  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 -245
  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 -201
  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 -426
  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.9a10.dist-info → batframework-1.0.9a12.dist-info}/LICENSE +20 -20
  69. {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/METADATA +24 -17
  70. batframework-1.0.9a12.dist-info/RECORD +72 -0
  71. batframework-1.0.9a10.dist-info/RECORD +0 -67
  72. {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/WHEEL +0 -0
  73. {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/top_level.txt +0 -0
batFramework/entity.py CHANGED
@@ -1,130 +1,130 @@
1
- from typing import Any, Self
2
- import pygame
3
- import batFramework as bf
4
- from typing import TYPE_CHECKING
5
-
6
- if TYPE_CHECKING:
7
- from .camera import Camera
8
-
9
-
10
- class Entity:
11
- _count: int = 0
12
- _available_uids: set[int] = set()
13
-
14
- def __init__(self,*args,**kwargs) -> None:
15
- if Entity._available_uids:
16
- self.uid = Entity._available_uids.pop()
17
- else:
18
- self.uid = Entity._count
19
- Entity._count += 1
20
-
21
- self.rect = pygame.FRect(0, 0, 10, 10)
22
- self.tags: list[str] = []
23
- self.parent_scene: bf.Scene | None = None
24
- self.parent_layer: bf.SceneLayer | None = None
25
- self.debug_color: tuple | str = "red"
26
-
27
- def __del__(self):
28
- try:
29
- Entity._available_uids.add(self.uid)
30
- except AttributeError:
31
- pass
32
- def set_position(self, x, y) -> Self:
33
- self.rect.topleft = x, y
34
- return self
35
-
36
- def set_center(self, x, y) -> Self:
37
- self.rect.center = x, y
38
- return self
39
-
40
- def get_debug_outlines(self):
41
- yield (self.rect, self.debug_color)
42
-
43
- def set_debug_color(self, color) -> Self:
44
- self.debug_color = color
45
- return self
46
-
47
- def kill(self):
48
- """
49
- Removes the entity from a scene layer
50
- """
51
- if self.parent_layer:
52
- self.parent_layer.remove(self)
53
-
54
- def set_parent_layer(self, layer):
55
- self.parent_layer = layer
56
-
57
- def set_parent_scene(self, scene) -> Self:
58
- if scene == self.parent_scene:
59
- return self
60
- if self.parent_scene is not None:
61
- self.do_when_removed()
62
- self.parent_scene = scene
63
- if scene is not None:
64
- self.do_when_added()
65
- return self
66
-
67
- def do_when_added(self):
68
- pass
69
-
70
- def do_when_removed(self):
71
- pass
72
-
73
- def add_tags(self, *tags) -> Self:
74
- for tag in tags:
75
- if tag not in self.tags:
76
- self.tags.append(tag)
77
- self.tags.sort()
78
- return self
79
-
80
- def remove_tags(self, *tags):
81
- self.tags = [tag for tag in self.tags if tag not in tags]
82
-
83
- def has_tags(self, *tags) -> bool:
84
- """
85
- return True if entity contains all given tags
86
- """
87
- return all(tag in self.tags for tag in tags)
88
-
89
- def has_any_tags(self, *tags) -> bool:
90
- """
91
- return True if entity contains any of given tags
92
- """
93
- return any(tag in self.tags for tag in tags)
94
-
95
- def get_tags(self) -> list[str]:
96
- return self.tags
97
-
98
- def process_event(self, event: pygame.Event) -> None:
99
- if event.consumed:
100
- return
101
- self.do_process_actions(event)
102
- self.do_handle_event(event)
103
-
104
- def do_process_actions(self, event: pygame.Event) -> None:
105
- """
106
- Process entity actions you may have set
107
- """
108
-
109
- def do_reset_actions(self) -> None:
110
- """
111
- Reset entity actions you may have set
112
- """
113
-
114
- def do_handle_event(self, event: pygame.Event):
115
- """
116
- Handle specific events with no action support
117
- """
118
- return False
119
-
120
- def update(self, dt: float) -> None:
121
- """
122
- Update method to be overriden by subclasses of Entity (must call do_update and do_reset_actions)
123
- """
124
- self.do_update(dt)
125
- self.do_reset_actions()
126
-
127
- def do_update(self, dt: float) -> None:
128
- """
129
- Update method to be overriden for specific behavior by the end user
130
- """
1
+ from typing import Any, Self
2
+ import pygame
3
+ import batFramework as bf
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from .camera import Camera
8
+
9
+
10
+ class Entity:
11
+ _count: int = 0
12
+ _available_uids: set[int] = set()
13
+
14
+ def __init__(self,*args,**kwargs) -> None:
15
+ if Entity._available_uids:
16
+ self.uid = Entity._available_uids.pop()
17
+ else:
18
+ self.uid = Entity._count
19
+ Entity._count += 1
20
+ size = kwargs.get("size",(10,10))
21
+ self.rect = pygame.FRect(0, 0, *size)
22
+ self.tags: list[str] = []
23
+ self.parent_scene: bf.Scene | None = None
24
+ self.parent_layer: bf.SceneLayer | None = None
25
+ self.debug_color: tuple | str = "red"
26
+
27
+ def __del__(self):
28
+ try:
29
+ Entity._available_uids.add(self.uid)
30
+ except AttributeError:
31
+ pass
32
+ def set_position(self, x, y) -> Self:
33
+ self.rect.topleft = x, y
34
+ return self
35
+
36
+ def set_center(self, x, y) -> Self:
37
+ self.rect.center = x, y
38
+ return self
39
+
40
+ def get_debug_outlines(self):
41
+ yield (self.rect, self.debug_color)
42
+
43
+ def set_debug_color(self, color) -> Self:
44
+ self.debug_color = color
45
+ return self
46
+
47
+ def kill(self):
48
+ """
49
+ Removes the entity from a scene layer
50
+ """
51
+ if self.parent_layer:
52
+ self.parent_layer.remove(self)
53
+
54
+ def set_parent_layer(self, layer):
55
+ self.parent_layer = layer
56
+
57
+ def set_parent_scene(self, scene) -> Self:
58
+ if scene == self.parent_scene:
59
+ return self
60
+ if self.parent_scene is not None:
61
+ self.do_when_removed()
62
+ self.parent_scene = scene
63
+ if scene is not None:
64
+ self.do_when_added()
65
+ return self
66
+
67
+ def do_when_added(self):
68
+ pass
69
+
70
+ def do_when_removed(self):
71
+ pass
72
+
73
+ def add_tags(self, *tags) -> Self:
74
+ for tag in tags:
75
+ if tag not in self.tags:
76
+ self.tags.append(tag)
77
+ self.tags.sort()
78
+ return self
79
+
80
+ def remove_tags(self, *tags):
81
+ self.tags = [tag for tag in self.tags if tag not in tags]
82
+
83
+ def has_tags(self, *tags) -> bool:
84
+ """
85
+ return True if entity contains all given tags
86
+ """
87
+ return all(tag in self.tags for tag in tags)
88
+
89
+ def has_any_tags(self, *tags) -> bool:
90
+ """
91
+ return True if entity contains any of given tags
92
+ """
93
+ return any(tag in self.tags for tag in tags)
94
+
95
+ def get_tags(self) -> list[str]:
96
+ return self.tags
97
+
98
+ def process_event(self, event: pygame.Event) -> None:
99
+ if event.consumed:
100
+ return
101
+ self.process_actions(event)
102
+ self.handle_event(event)
103
+
104
+ def process_actions(self, event: pygame.Event) -> None:
105
+ """
106
+ Process entity actions you may have set
107
+ """
108
+
109
+ def reset_actions(self) -> None:
110
+ """
111
+ Reset entity actions you may have set
112
+ """
113
+
114
+ def handle_event(self, event: pygame.Event):
115
+ """
116
+ Handle specific events with no action support
117
+ """
118
+ return False
119
+
120
+ def update(self, dt: float) -> None:
121
+ """
122
+ Update method to be overriden by subclasses of Entity (must call do_update and reset_actions)
123
+ """
124
+ self.do_update(dt)
125
+ self.reset_actions()
126
+
127
+ def do_update(self, dt: float) -> None:
128
+ """
129
+ Update method to be overriden for specific behavior by the end user
130
+ """
batFramework/enums.py CHANGED
@@ -1,135 +1,171 @@
1
- from enum import Enum
2
- import pygame
3
-
4
- playerInput = [pygame.KEYDOWN,pygame.MOUSEBUTTONDOWN,pygame.KEYUP,pygame.MOUSEBUTTONUP]
5
-
6
- class color:
7
- WHITE = pygame.Color(255, 255, 255)
8
- LIGHTER_GRAY = pygame.Color(236, 240, 241)
9
- LIGHT_GRAY = pygame.Color(189, 195, 199)
10
- DARK_GRAY = pygame.Color(66, 66, 66)
11
- DARKER_GRAY = pygame.Color(23, 23, 23)
12
- BLACK = pygame.Color(0, 0, 0)
13
-
14
- TURQUOISE = pygame.Color(26, 188, 156)
15
- TURQUOISE_SHADE = pygame.Color(22, 160, 133)
16
-
17
- GREEN = pygame.Color(46, 204, 113)
18
- GREEN_SHADE = pygame.Color(39, 174, 96)
19
-
20
- BLUE = pygame.Color(52, 152, 219)
21
- BLUE_SHADE = pygame.Color(41, 128, 185)
22
-
23
- PURPLE = pygame.Color(155, 89, 182)
24
- PURPLE_SHADE = pygame.Color(142, 68, 173)
25
-
26
- CHARCOAL = pygame.Color(52, 73, 94)
27
- CHARCOAL_SHADE = pygame.Color(44, 62, 80)
28
-
29
- GOLD = pygame.Color(241, 196, 15)
30
- GOLD_SHADE = pygame.Color(243, 156, 18)
31
-
32
- ORANGE = pygame.Color(230, 126, 34)
33
- ORANGE_SHADE = pygame.Color(211, 84, 0)
34
-
35
- RED = pygame.Color(231, 76, 60)
36
- RED_SHADE = pygame.Color(192, 57, 43)
37
-
38
- CLOUD = pygame.Color(236, 240, 241)
39
- CLOUD_SHADE = pygame.Color(189, 195, 199)
40
-
41
- CONCRETE = pygame.Color(149, 165, 166)
42
- CONCRETE_SHADE = pygame.Color(127, 140, 141)
43
-
44
- # GB
45
- DARKER_GB = pygame.Color(27, 42, 9)
46
- DARK_GB = pygame.Color(14, 69, 11)
47
- LIGHT_GB = pygame.Color(73, 107, 34)
48
- LIGHTER_GB = pygame.Color(154, 158, 63)
49
-
50
- @staticmethod
51
- def mult(color: pygame.Color, factor: float):
52
- return pygame.Color(
53
- min(max(0, int(color.r * factor)), 255),
54
- min(max(0, int(color.g * factor)), 255),
55
- min(max(0, int(color.b * factor)), 255),
56
- color.a
57
- )
58
-
59
- class easing(Enum):
60
- LINEAR = (0, 0, 1, 1)
61
- EASE_IN = (0.95, 0, 1, 0.55)
62
- EASE_OUT = (0.5, 1, 0.5, 1)
63
- EASE_IN_OUT = (0.55, 0, 0.45, 1)
64
- EASE_IN_OUT_ELASTIC = (0.76,-0.36,0.41,1.34)
65
-
66
- def __init__(self, *control_points):
67
- self.control_points = control_points
68
-
69
- @classmethod
70
- def create(cls, *control_points):
71
- """Create a custom easing instance."""
72
- instance = object.__new__(cls)
73
- instance._value_ = control_points
74
- instance.control_points = control_points
75
- return instance
76
-
77
- class axis(Enum):
78
- HORIZONTAL = "horizontal"
79
- VERTICAL = "vertical"
80
-
81
-
82
- class spacing(Enum):
83
- MIN = "min"
84
- HALF = "half"
85
- MAX = "max"
86
- MANUAL = "manual"
87
-
88
-
89
- class alignment(Enum):
90
- LEFT = "left"
91
- RIGHT = "right"
92
- CENTER = "center"
93
- TOP = "top"
94
- BOTTOM = "bottom"
95
- TOPLEFT = "topleft"
96
- TOPRIGHT = "topright"
97
- MIDLEFT = "midleft"
98
- MIDRIGHT = "midright"
99
- MIDTOP = "midtop"
100
- MIDBOTTOM = "midbottom"
101
- BOTTOMLEFT = "bottomleft"
102
- BOTTOMRIGHT = "bottomright"
103
-
104
-
105
- class direction(Enum):
106
- LEFT = 0
107
- UP = 1
108
- RIGHT = 2
109
- DOWN = 3
110
-
111
-
112
- class drawMode(Enum):
113
- SOLID = 0
114
- TEXTURED = 1
115
-
116
-
117
- class debugMode(Enum):
118
- HIDDEN = 0
119
- DEBUGGER = 1
120
- OUTLINES = 2
121
-
122
-
123
- class actionType(Enum):
124
- INSTANTANEOUS = 0
125
- CONTINUOUS = 1
126
- HOLDING = 2
127
-
128
-
129
- class textMode(Enum):
130
- ALPHABETICAL = 0
131
- NUMERICAL = 1
132
- ALPHANUMERICAL = 3
133
-
134
-
135
-
1
+ from enum import Enum
2
+ import pygame
3
+
4
+ playerInput = [pygame.KEYDOWN,pygame.MOUSEBUTTONDOWN,pygame.KEYUP,pygame.MOUSEBUTTONUP]
5
+
6
+ class color:
7
+ WHITE = pygame.Color(255, 255, 255)
8
+ LIGHTER_GRAY = pygame.Color(236, 240, 241)
9
+ LIGHT_GRAY = pygame.Color(189, 195, 199)
10
+ DARK_GRAY = pygame.Color(66, 66, 66)
11
+ DARKER_GRAY = pygame.Color(23, 23, 23)
12
+ BLACK = pygame.Color(0, 0, 0)
13
+
14
+ TURQUOISE = pygame.Color(26, 188, 156)
15
+ TURQUOISE_SHADE = pygame.Color(22, 160, 133)
16
+
17
+ GREEN = pygame.Color(46, 204, 113)
18
+ GREEN_SHADE = pygame.Color(39, 174, 96)
19
+
20
+ BLUE = pygame.Color(52, 152, 219)
21
+ BLUE_SHADE = pygame.Color(41, 128, 185)
22
+
23
+ PURPLE = pygame.Color(155, 89, 182)
24
+ PURPLE_SHADE = pygame.Color(142, 68, 173)
25
+
26
+ CHARCOAL = pygame.Color(52, 73, 94)
27
+ CHARCOAL_SHADE = pygame.Color(44, 62, 80)
28
+
29
+ GOLD = pygame.Color(241, 196, 15)
30
+ GOLD_SHADE = pygame.Color(243, 156, 18)
31
+
32
+ ORANGE = pygame.Color(230, 126, 34)
33
+ ORANGE_SHADE = pygame.Color(211, 84, 0)
34
+
35
+ RED = pygame.Color(231, 76, 60)
36
+ RED_SHADE = pygame.Color(192, 57, 43)
37
+
38
+ CLOUD = pygame.Color(236, 240, 241)
39
+ CLOUD_SHADE = pygame.Color(189, 195, 199)
40
+
41
+ CONCRETE = pygame.Color(149, 165, 166)
42
+ CONCRETE_SHADE = pygame.Color(127, 140, 141)
43
+
44
+ # GB
45
+ DARKER_GB = pygame.Color(27, 42, 9)
46
+ DARK_GB = pygame.Color(14, 69, 11)
47
+ LIGHT_GB = pygame.Color(73, 107, 34)
48
+ LIGHTER_GB = pygame.Color(154, 158, 63)
49
+
50
+ @classmethod
51
+ def __iter__(cls):
52
+ for name, value in vars(cls).items():
53
+ if not name.startswith("__") and isinstance(value, pygame.Color):
54
+ yield value
55
+
56
+ @classmethod
57
+ def items(cls):
58
+ """Iterate over (name, color) pairs."""
59
+ for name, value in vars(cls).items():
60
+ if not name.startswith("__") and isinstance(value, pygame.Color):
61
+ yield name, value
62
+
63
+ @staticmethod
64
+ def mult(color: pygame.typing.ColorLike , factor: float):
65
+ color = pygame.Color(color)
66
+ return pygame.Color(
67
+ min(max(0, int(color[0] * factor)), 255),
68
+ min(max(0, int(color[1] * factor)), 255),
69
+ min(max(0, int(color[2] * factor)), 255),
70
+ color[3] if len(color)== 4 else 255
71
+ )
72
+
73
+ @staticmethod
74
+ def lerp(color1: pygame.Color | tuple[int, int, int, int], color2: pygame.Color | tuple[int, int, int, int], t: float) -> pygame.Color:
75
+ """Linearly interpolate between two colors."""
76
+ t = max(0.0, min(1.0, t))
77
+ c1 = color1 if isinstance(color1, (tuple, list)) else (color1.r, color1.g, color1.b, color1.a)
78
+ c2 = color2 if isinstance(color2, (tuple, list)) else (color2.r, color2.g, color2.b, color2.a)
79
+ return pygame.Color(
80
+ int(c1[0] + (c2[0] - c1[0]) * t),
81
+ int(c1[1] + (c2[1] - c1[1]) * t),
82
+ int(c1[2] + (c2[2] - c1[2]) * t),
83
+ int((c1[3] if len(c1) > 3 else 255) + ((c2[3] if len(c2) > 3 else 255) - (c1[3] if len(c1) > 3 else 255)) * t)
84
+ )
85
+
86
+ @staticmethod
87
+ def get_name(color_value:pygame.Color):
88
+ for name, val in color.__dict__.items():
89
+ # Only consider attributes that are pygame.Color instances
90
+ if isinstance(val, pygame.Color) and val == color_value:
91
+ return name
92
+ return str(color_value)
93
+
94
+
95
+ class easing(Enum):
96
+ LINEAR = (0, 0, 1, 1)
97
+ EASE_IN = (0.95, 0, 1, 0.55)
98
+ EASE_OUT = (0.5, 1, 0.5, 1)
99
+ EASE_IN_OUT = (0.55, 0, 0.45, 1)
100
+ EASE_IN_OUT_ELASTIC = (0.76,-0.36,0.41,1.34)
101
+
102
+ def __init__(self, *control_points):
103
+ self.control_points = control_points
104
+
105
+ @classmethod
106
+ def create(cls, *control_points):
107
+ """Create a custom easing instance."""
108
+ instance = object.__new__(cls)
109
+ instance._value_ = control_points
110
+ instance.control_points = control_points
111
+ return instance
112
+
113
+ class axis(Enum):
114
+ HORIZONTAL = "horizontal"
115
+ VERTICAL = "vertical"
116
+
117
+
118
+ class spacing(Enum):
119
+ MIN = "min"
120
+ HALF = "half"
121
+ MAX = "max"
122
+ MANUAL = "manual"
123
+
124
+
125
+ class alignment(Enum):
126
+ LEFT = "left"
127
+ RIGHT = "right"
128
+ CENTER = "center"
129
+ TOP = "top"
130
+ BOTTOM = "bottom"
131
+ TOPLEFT = "topleft"
132
+ TOPRIGHT = "topright"
133
+ MIDLEFT = "midleft"
134
+ MIDRIGHT = "midright"
135
+ MIDTOP = "midtop"
136
+ MIDBOTTOM = "midbottom"
137
+ BOTTOMLEFT = "bottomleft"
138
+ BOTTOMRIGHT = "bottomright"
139
+
140
+
141
+ class direction(Enum):
142
+ LEFT = 0
143
+ UP = 1
144
+ RIGHT = 2
145
+ DOWN = 3
146
+
147
+
148
+ class drawMode(Enum):
149
+ SOLID = 0
150
+ TEXTURED = 1
151
+
152
+
153
+ class debugMode(Enum):
154
+ HIDDEN = 0
155
+ DEBUGGER = 1
156
+ OUTLINES = 2
157
+
158
+
159
+ class actionType(Enum):
160
+ INSTANTANEOUS = 0
161
+ CONTINUOUS = 1
162
+ HOLDING = 2
163
+
164
+
165
+ class textMode(Enum):
166
+ ALPHABETICAL = 0
167
+ NUMERICAL = 1
168
+ ALPHANUMERICAL = 3
169
+
170
+
171
+