batframework 1.0.8a8__py3-none-any.whl → 1.0.8a10__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 +68 -51
- batFramework/action.py +126 -99
- batFramework/actionContainer.py +53 -9
- batFramework/animatedSprite.py +141 -82
- batFramework/audioManager.py +69 -26
- batFramework/camera.py +259 -69
- batFramework/character.py +27 -0
- batFramework/constants.py +16 -54
- batFramework/cutscene.py +39 -29
- batFramework/cutsceneBlocks.py +36 -43
- batFramework/dynamicEntity.py +18 -9
- batFramework/easingController.py +58 -0
- batFramework/entity.py +48 -97
- batFramework/enums.py +113 -0
- batFramework/fontManager.py +65 -0
- batFramework/gui/__init__.py +10 -2
- batFramework/gui/button.py +9 -78
- batFramework/gui/clickableWidget.py +220 -0
- batFramework/gui/constraints/__init__.py +1 -0
- batFramework/gui/constraints/constraints.py +815 -0
- batFramework/gui/container.py +174 -32
- batFramework/gui/debugger.py +131 -43
- batFramework/gui/dialogueBox.py +99 -0
- batFramework/gui/draggableWidget.py +40 -0
- batFramework/gui/image.py +56 -20
- batFramework/gui/indicator.py +38 -21
- batFramework/gui/interactiveWidget.py +192 -13
- batFramework/gui/label.py +309 -74
- batFramework/gui/layout.py +231 -63
- batFramework/gui/meter.py +74 -0
- batFramework/gui/radioButton.py +84 -0
- batFramework/gui/root.py +134 -38
- batFramework/gui/shape.py +237 -57
- batFramework/gui/slider.py +240 -0
- batFramework/gui/style.py +10 -0
- batFramework/gui/styleManager.py +48 -0
- batFramework/gui/textInput.py +247 -0
- batFramework/gui/toggle.py +101 -51
- batFramework/gui/widget.py +358 -250
- batFramework/manager.py +52 -19
- batFramework/object.py +123 -0
- batFramework/particle.py +115 -0
- batFramework/renderGroup.py +67 -0
- batFramework/resourceManager.py +100 -0
- batFramework/scene.py +281 -123
- batFramework/sceneManager.py +178 -116
- batFramework/scrollingSprite.py +114 -0
- batFramework/sprite.py +51 -0
- batFramework/stateMachine.py +11 -8
- batFramework/templates/__init__.py +2 -0
- batFramework/templates/character.py +44 -0
- batFramework/templates/states.py +166 -0
- batFramework/tileset.py +46 -0
- batFramework/time.py +145 -58
- batFramework/transition.py +195 -124
- batFramework/triggerZone.py +1 -1
- batFramework/utils.py +112 -147
- batframework-1.0.8a10.dist-info/LICENCE +21 -0
- batframework-1.0.8a10.dist-info/METADATA +43 -0
- batframework-1.0.8a10.dist-info/RECORD +62 -0
- batFramework/debugger.py +0 -48
- batFramework/easing.py +0 -71
- batFramework/gui/constraints.py +0 -204
- batFramework/gui/frame.py +0 -19
- batFramework/particles.py +0 -77
- batFramework/transitionManager.py +0 -0
- batframework-1.0.8a8.dist-info/METADATA +0 -53
- batframework-1.0.8a8.dist-info/RECORD +0 -42
- {batframework-1.0.8a8.dist-info → batframework-1.0.8a10.dist-info}/WHEEL +0 -0
- {batframework-1.0.8a8.dist-info → batframework-1.0.8a10.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: batframework
|
3
|
+
Version: 1.0.8a10
|
4
|
+
Summary: Pygame framework for making games easier.
|
5
|
+
Author-email: Turan Baturay <baturayturan@gmail.com>
|
6
|
+
Project-URL: Homepage, https://github.com/TuranBaturay/batFramework
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.11
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENCE
|
13
|
+
Requires-Dist: pygame-ce
|
14
|
+
|
15
|
+
# batFramework
|
16
|
+
|
17
|
+
Welcome to the `batFramework`. This README provides an overview of the game framework.
|
18
|
+
|
19
|
+
## batFramework
|
20
|
+
|
21
|
+
The `batFramework` is a Python game development framework based on pygame, designed to streamline the process of creating 2D games. It provides a set of tools and components to handle scenes, transitions, cutscenes, audio, sprites, and more. The framework is built with flexibility in mind, allowing you to focus on game design while abstracting away low-level details.
|
22
|
+
|
23
|
+
### Features
|
24
|
+
|
25
|
+
- Scene management
|
26
|
+
- Cutscene support
|
27
|
+
- Audio management (music and sound effects with volume control)
|
28
|
+
- Entity, sprite, and animated sprite handling
|
29
|
+
- Transition effects
|
30
|
+
- Utility modules (time management, constants, etc.)
|
31
|
+
- No external dependency except for pygame
|
32
|
+
|
33
|
+
### Explore batFramework
|
34
|
+
|
35
|
+
1. Install Python (version 3.11 or higher) and the latest stable version of pygame-ce.
|
36
|
+
2. Clone or download this repository.
|
37
|
+
4. Explore the framework's modules in the `batFramework` directory and integrate them into your own game project.
|
38
|
+
|
39
|
+
For more detailed information on how to use the framework, refer to the documentation (if available) or explore the source code in the `batFramework` directory.
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
batFramework/__init__.py,sha256=ZMA14nsYaYN4_0a0J1la_Mq-fvFe7TBVfN25dP-pMSY,2556
|
2
|
+
batFramework/action.py,sha256=919IVYKviLyVYDtQL7oZvlVuE_aodjJCuwz6fGi5sCk,8420
|
3
|
+
batFramework/actionContainer.py,sha256=qy6-YY3iX26KJ8NqFMSYo6JExohD8HFk0sC1qhb7qA8,2602
|
4
|
+
batFramework/animatedSprite.py,sha256=Y77nakxq_UIAogeJRrs0VCK9n8teFHjsK5GE4sZ0q3U,6011
|
5
|
+
batFramework/audioManager.py,sha256=8tKSf4huZe5tgH98qHlKoFNjXPGDQNJho6PKfSCe7JA,3869
|
6
|
+
batFramework/camera.py,sha256=u1EPSitZ9mEEa32yQB7K6ywnWgWCSumbhrc4HRjimEY,9406
|
7
|
+
batFramework/character.py,sha256=IRsDclTTkA-sb51-LgcVjQW3slfA-8H_8wMA5LL-KlA,760
|
8
|
+
batFramework/constants.py,sha256=5PyZQZ4fCcLA8k_Upby9KGVF-3pnV2ZZ6t26CxiocPM,1102
|
9
|
+
batFramework/cutscene.py,sha256=Jh2g-zC3zaUSQoO2uVOsirWkuLAUFugu2T8B_ob9IPQ,4007
|
10
|
+
batFramework/cutsceneBlocks.py,sha256=3jtmTpV48NKCu-Qgjg7KN5KnwXn0kycIQ7t7G3RH3VE,4862
|
11
|
+
batFramework/dynamicEntity.py,sha256=6WcI6OveFNmrtOUYzmVMlT35Hz4MXeeRKzd1M3meL1Q,876
|
12
|
+
batFramework/easingController.py,sha256=4N8GIp1fsaWBUlDxXx3SMwOq1Mrhn10MZZIO51_CRnk,1677
|
13
|
+
batFramework/entity.py,sha256=34gYC6uEMmLkqWtoTG9bgMWRmHRSxhQfxXZKzWS7H2o,2127
|
14
|
+
batFramework/enums.py,sha256=re12gHw2g-5qtCNmGOfZbEC5cL5E8-FA79hfKGrI6-I,2078
|
15
|
+
batFramework/fontManager.py,sha256=iCVavr4hpn0T4xsaUAzdNd01j5ebpcj30fvFHzm1g-M,2246
|
16
|
+
batFramework/manager.py,sha256=LilVu1M42-tWNQeFjGXdPTTPHot1z8bRBoIFzNbxXUw,2754
|
17
|
+
batFramework/object.py,sha256=_3sfRxrjaiDuVyz5Yk-fYJqYx-Ehq_3-dA4eDTb9kok,3329
|
18
|
+
batFramework/particle.py,sha256=SD_DRqfhzlEeWlORDVPh1R__2_RplNcBujmqovN9Mww,3079
|
19
|
+
batFramework/renderGroup.py,sha256=_VDvmP4iB-XarFJo_Uh5YKwWq1cazHmOBmTXZkqKk40,2020
|
20
|
+
batFramework/resourceManager.py,sha256=0cOIAFXT7UzzvgHn9QkWcXsTp8H2bIS70NvvgpBL2_4,3554
|
21
|
+
batFramework/scene.py,sha256=2fXxwle68jzHwR2irKeWJYL95uAVmmU2edexo9p7fu4,12197
|
22
|
+
batFramework/sceneManager.py,sha256=Jb51KksIDrZrXUafs0bgX73tY-8rglWW89Co48YGdCM,8037
|
23
|
+
batFramework/scrollingSprite.py,sha256=PPEieAaFcOLE_Lm7cnm3xc7XyLKopCPcDbXEfyThO48,4133
|
24
|
+
batFramework/sprite.py,sha256=t_kSyUXGOSXQbSBwrKgBUTp5mITeFQbAKNzugjL5SgY,1625
|
25
|
+
batFramework/stateMachine.py,sha256=wC-5xbKvf-vGm_N16X9KhgMya5915GyVXL79uk5Bapw,1359
|
26
|
+
batFramework/tileset.py,sha256=3AJBWHx90PC43BdLYCBFm811XBrMvWoB-nsUgyo6s-I,1728
|
27
|
+
batFramework/time.py,sha256=iLDuHPQVNcPrNfqN6UP67d34HuC8Y42s6cdiTE53o7o,4989
|
28
|
+
batFramework/transition.py,sha256=-1cyk-7Fbm0U2Z4Y2jjpLHwJ2khM1VxIMcfk2bBEo-M,6655
|
29
|
+
batFramework/triggerZone.py,sha256=wIxkvO0cVVupQsJIPOD_-ofqwLnu1TLNK-n6oNXB1E8,579
|
30
|
+
batFramework/utils.py,sha256=kj0qaOwpwvvPMD1DyOQTZLYeV-1lJ0dobeU2E49Rwg8,5215
|
31
|
+
batFramework/gui/__init__.py,sha256=17ij7mrCBCoehqCq1PV6MSXPOfMoLPmrV_G8d6ax4Tk,687
|
32
|
+
batFramework/gui/button.py,sha256=Ozs6VKHf9FCQXQODDiLQywGN3hwfXtQ6s2I-rzdjnQg,429
|
33
|
+
batFramework/gui/clickableWidget.py,sha256=2vS9GFSI3uufYQbaosXxTMs81vyVfQGz71AeZmf8vcY,7049
|
34
|
+
batFramework/gui/container.py,sha256=wXjuhwCJc71KKSgY2cYgoRscAKB_hIw5N4njJk3Z9lk,5925
|
35
|
+
batFramework/gui/debugger.py,sha256=XogxF3J31GO-DZZn6YBrgwpYA5WjadzEfHkQHeMLU7o,3925
|
36
|
+
batFramework/gui/dialogueBox.py,sha256=3Z76l9obrpQImI8hjoBS_8G9sY3UILj2d3nJsaxtaI4,3221
|
37
|
+
batFramework/gui/draggableWidget.py,sha256=SKG7oMInZ_GTnrbv2T0aqlppuiuLX1tkVSCQJtRMlk8,1392
|
38
|
+
batFramework/gui/image.py,sha256=7IRvalA6QQz7SYI9h4y4-ryWa9EOxZM3sc10-OZyCPc,1770
|
39
|
+
batFramework/gui/indicator.py,sha256=leCvxsGxt00-oTn0N5MTmLstLH9uLG3RjQ02KlXtZCQ,1549
|
40
|
+
batFramework/gui/interactiveWidget.py,sha256=FAZnSlMIohduZIDTZh5U-_mh1AbgTF4sz-0oig4LWIQ,5760
|
41
|
+
batFramework/gui/label.py,sha256=RcC0XY4hOuMkzBqRi1JeYPAykJ-bXjP37xqmr257FbY,11818
|
42
|
+
batFramework/gui/layout.py,sha256=vGEifD5HZqz3fd6TRU0Xr7_1czLlpqe450mam48cLk0,8587
|
43
|
+
batFramework/gui/meter.py,sha256=RFzAhSzR3O-Pw0wjdfApWGWFQSJoYa4WohkiREDAAJc,2395
|
44
|
+
batFramework/gui/radioButton.py,sha256=rROl9mtUa-m220R5qZ85NBPZS7nPVx-azhqijJ-XhCo,2411
|
45
|
+
batFramework/gui/root.py,sha256=K75814ct6AF4LF8cyzmtUmnTmSflJRnHVMGbpUXwmkE,5084
|
46
|
+
batFramework/gui/shape.py,sha256=Ros_-Mm2Q2CFauZFqFPh1QyyuZnNmg7C2PYbs7Cq41k,9347
|
47
|
+
batFramework/gui/slider.py,sha256=5d3rfTYjDCDiM5prKu6DTemlGgji2FQ_vGuLzxoa5gU,8335
|
48
|
+
batFramework/gui/style.py,sha256=OeLbft0RkIslQ2IcZpBeF6TaQDONIoBcAHj_Bkh9gFw,131
|
49
|
+
batFramework/gui/styleManager.py,sha256=rALKJ-AmRbDAiyu8hVAYRAlkQxw677DiPoNKJZ4xtJ4,1245
|
50
|
+
batFramework/gui/textInput.py,sha256=aTegghN6O3djL0eBEEij9DsEuZ1MyE61P51IzaLUUEg,9324
|
51
|
+
batFramework/gui/toggle.py,sha256=XLFzCRaY7uOkKFVtR3y01wsNjLjZqrS1748IcvBRN2Q,3969
|
52
|
+
batFramework/gui/widget.py,sha256=HGusTCgh3oAjtvrShzn2YxhFTGgNLsqGGhNilvRx-oo,13883
|
53
|
+
batFramework/gui/constraints/__init__.py,sha256=qqXE8nnSrEvCSeHdqY8UYPZLetqdubFPI7IdZuh35QE,26
|
54
|
+
batFramework/gui/constraints/constraints.py,sha256=nyPew0HIJ24rl4JcdBjUYu2aFynTryN9wqv1wKCo4ew,26873
|
55
|
+
batFramework/templates/__init__.py,sha256=8XN-7JwYFKTRx_lnUL_If3spwgn5_2b7bwmrRRBPON0,46
|
56
|
+
batFramework/templates/character.py,sha256=S-EkKYrMPg6539r1I5xNf9_bNVIC5-wISIJundbTlBQ,1319
|
57
|
+
batFramework/templates/states.py,sha256=WeomVrQ10vHxVCj9Wnk1PcinKyb871uV910mQe287kI,5370
|
58
|
+
batframework-1.0.8a10.dist-info/LICENCE,sha256=A65iXbMDbOxQLDNOODJLqA7o5RxszYlEqIgNSzBQRf4,1073
|
59
|
+
batframework-1.0.8a10.dist-info/METADATA,sha256=kH-1UVijre_Mc52ezMtLd8XEtaoDRqpRgMqYUvBdkiY,1695
|
60
|
+
batframework-1.0.8a10.dist-info/WHEEL,sha256=5Mi1sN9lKoFv_gxcPtisEVrJZihrm_beibeg5R6xb4I,91
|
61
|
+
batframework-1.0.8a10.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
|
62
|
+
batframework-1.0.8a10.dist-info/RECORD,,
|
batFramework/debugger.py
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
import batFramework as bf
|
2
|
-
import pygame
|
3
|
-
|
4
|
-
|
5
|
-
class Debugger(bf.Label):
|
6
|
-
def __init__(self, manager) -> None:
|
7
|
-
super().__init__()
|
8
|
-
self.manager: bf.Manager = manager
|
9
|
-
self.refresh_rate = 0
|
10
|
-
self._refresh_counter = 0
|
11
|
-
self.dynamic_data = {}
|
12
|
-
self.static_data = {}
|
13
|
-
self.render_order = 99
|
14
|
-
self.set_outline_color((20, 20, 20))
|
15
|
-
# self.set_background_color((0,0,0,0))
|
16
|
-
self.set_text_color("white")
|
17
|
-
# self.set_padding((30,30))
|
18
|
-
self.set_refresh_rate(20)
|
19
|
-
self.add_dynamic_data("FPS", lambda: str(round(self.manager.get_fps())))
|
20
|
-
self.add_dynamic_data("BLITS", lambda: str(self.parent_scene.blit_calls))
|
21
|
-
self.set_visible(False)
|
22
|
-
|
23
|
-
def set_refresh_rate(self, val: int):
|
24
|
-
self.refresh_rate = val
|
25
|
-
|
26
|
-
def update(self, dt: float):
|
27
|
-
visible = self.manager._debugging == 1
|
28
|
-
self.set_visible(visible)
|
29
|
-
if not visible:
|
30
|
-
return
|
31
|
-
self._refresh_counter -= dt * 60
|
32
|
-
if self._refresh_counter < 0:
|
33
|
-
self._refresh_counter = self.refresh_rate
|
34
|
-
self._refresh_debug_info()
|
35
|
-
|
36
|
-
def add_dynamic_data(self, key, func):
|
37
|
-
self.dynamic_data[key] = func
|
38
|
-
|
39
|
-
def set_static_data(self, key, value):
|
40
|
-
self.static_data[key] = value
|
41
|
-
|
42
|
-
def _refresh_debug_info(self):
|
43
|
-
lines = []
|
44
|
-
lines.extend([f"{key}:{value}" for key, value in self.static_data.items()])
|
45
|
-
lines.extend([f"{key}:{func()}" for key, func in self.dynamic_data.items()])
|
46
|
-
debug_text = "\n".join(lines)
|
47
|
-
self.set_text(debug_text)
|
48
|
-
self.update_surface() # Update the surface after modifying the text
|
batFramework/easing.py
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
import pygame
|
3
|
-
import batFramework as bf
|
4
|
-
|
5
|
-
class Easing(Enum):
|
6
|
-
EASE_IN = (0.12, 0, 0.39, 0)
|
7
|
-
EASE_OUT = (0.61, 1, 0.88, 1)
|
8
|
-
EASE_IN_OUT = (0.37, 0, 0.63, 1)
|
9
|
-
EASE_IN_OUT_ELASTIC = (.7,-0.5,.3,1.5)
|
10
|
-
LINEAR = (1, 1, 0, 0)
|
11
|
-
# Add more easing functions as needed
|
12
|
-
|
13
|
-
def __init__(self, *control_points):
|
14
|
-
self.control_points = control_points
|
15
|
-
|
16
|
-
class EasingAnimation(bf.Timer):
|
17
|
-
_cache = {}
|
18
|
-
def __init__(
|
19
|
-
self,
|
20
|
-
name:str=None,
|
21
|
-
easing_function:Easing=Easing.LINEAR,
|
22
|
-
duration:int=100,
|
23
|
-
update_callback=None,
|
24
|
-
end_callback=None,
|
25
|
-
loop:bool=False,
|
26
|
-
reusable:bool=False
|
27
|
-
):
|
28
|
-
self.easing_function = easing_function
|
29
|
-
self.update_callback = update_callback
|
30
|
-
self.value = 0.0
|
31
|
-
super().__init__(name,duration,loop,end_callback,reusable)
|
32
|
-
|
33
|
-
def get_value(self):
|
34
|
-
return self.value
|
35
|
-
|
36
|
-
def start(self):
|
37
|
-
self.value = 0
|
38
|
-
super().start() # self.elapsed_progress set to 0 here
|
39
|
-
|
40
|
-
def update(self)->bool:
|
41
|
-
if super().update():
|
42
|
-
return True# If timer ended now, end() is called. So don't process value.
|
43
|
-
self._process_value()
|
44
|
-
# if self.name == 0: print("UPDATING (callback) in easing")
|
45
|
-
if self.update_callback: self.update_callback(self.value)
|
46
|
-
return False
|
47
|
-
|
48
|
-
def end(self):
|
49
|
-
# Call update 1 last time with the last value
|
50
|
-
|
51
|
-
self.elapsed_progress = 1
|
52
|
-
self._process_value()
|
53
|
-
if self.update_callback: self.update_callback(self.value)
|
54
|
-
self.value = 0
|
55
|
-
super().end() # sets elapsed_progress to 0
|
56
|
-
|
57
|
-
def _process_value(self):
|
58
|
-
p0, p1, p2, p3 = self.easing_function.control_points
|
59
|
-
cache_key = (self.elapsed_progress, p0, p1, p2, p3)
|
60
|
-
if cache_key in EasingAnimation._cache:
|
61
|
-
y = EasingAnimation._cache[cache_key]
|
62
|
-
else:
|
63
|
-
t = self.elapsed_progress
|
64
|
-
t_inv = 1.0 - t
|
65
|
-
t2 = t * t
|
66
|
-
t3 = t * t2
|
67
|
-
t_inv2 = t_inv * t_inv
|
68
|
-
|
69
|
-
y = 3 * t_inv2 * t * p1 + 3 * t_inv * t2 * p3 + t3
|
70
|
-
EasingAnimation._cache[cache_key] = y
|
71
|
-
self.value = y
|
batFramework/gui/constraints.py
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
from .widget import Widget
|
2
|
-
import batFramework as bf
|
3
|
-
|
4
|
-
|
5
|
-
class Constraint:
|
6
|
-
def __init__(self,name="Constraint", priority=0):
|
7
|
-
self.priority = priority
|
8
|
-
self.name = name
|
9
|
-
def set_priority(self, priority)->"Constraint":
|
10
|
-
self.priority = priority
|
11
|
-
return self
|
12
|
-
def to_string(self)->str:
|
13
|
-
return f"{self.name.upper()}"
|
14
|
-
|
15
|
-
def evaluate(self, parent_widget:Widget, child_widget:Widget) -> bool:
|
16
|
-
raise NotImplementedError("Subclasses must implement evaluate method")
|
17
|
-
|
18
|
-
def apply(self, parent_widget:Widget, child_widget:Widget=None) -> bool:
|
19
|
-
if not self.evaluate(parent_widget, child_widget):
|
20
|
-
self.apply_constraint(parent_widget, child_widget)
|
21
|
-
return False
|
22
|
-
return True
|
23
|
-
|
24
|
-
def apply_constraint(self, parent_widget:Widget, child_widget:Widget):
|
25
|
-
raise NotImplementedError("Subclasses must implement apply_constraint method")
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
class ConstraintMinWidth(Constraint):
|
43
|
-
def __init__(self, width):
|
44
|
-
super().__init__(name="min_width")
|
45
|
-
self.min_width = width
|
46
|
-
|
47
|
-
def evaluate(self, parent_widget, child_widget):
|
48
|
-
return child_widget.rect.width >= self.min_width
|
49
|
-
|
50
|
-
def apply_constraint(self, parent_widget, child_widget):
|
51
|
-
if not self.evaluate(parent_widget, child_widget):
|
52
|
-
child_widget.set_size(self.min_width,child_widget.rect.h)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
class ConstraintCenterX(Constraint):
|
58
|
-
def __init__(self):
|
59
|
-
super().__init__(name="centerx")
|
60
|
-
|
61
|
-
def evaluate(self, parent_widget, child_widget):
|
62
|
-
return child_widget.rect.centerx == parent_widget.get_content_center()[0]
|
63
|
-
|
64
|
-
def apply_constraint(self,parent_widget,child_widget):
|
65
|
-
if not self.evaluate(parent_widget,child_widget):
|
66
|
-
child_widget.set_center(parent_widget.get_content_center()[0],child_widget.rect.centery)
|
67
|
-
|
68
|
-
class ConstraintCenterY(Constraint):
|
69
|
-
def __init__(self):
|
70
|
-
super().__init__(name="centery")
|
71
|
-
|
72
|
-
def evaluate(self, parent_widget, child_widget):
|
73
|
-
return child_widget.rect.centery == parent_widget.get_content_center()[1]
|
74
|
-
|
75
|
-
def apply_constraint(self,parent_widget,child_widget):
|
76
|
-
if not self.evaluate(parent_widget,child_widget):
|
77
|
-
child_widget.set_center(child_widget.rect.centerx,parent_widget.get_content_center()[1])
|
78
|
-
|
79
|
-
class ConstraintCenter(Constraint):
|
80
|
-
def __init__(self):
|
81
|
-
super().__init__(name="center")
|
82
|
-
|
83
|
-
def evaluate(self, parent_widget, child_widget):
|
84
|
-
return child_widget.rect.center == parent_widget.get_content_center()
|
85
|
-
|
86
|
-
def apply_constraint(self,parent_widget,child_widget):
|
87
|
-
if not self.evaluate(parent_widget,child_widget):
|
88
|
-
child_widget.set_center(*parent_widget.get_content_center())
|
89
|
-
|
90
|
-
class ConstraintPercentageWidth(Constraint):
|
91
|
-
def __init__(self,percentage:float,keep_autoresize:bool=True):
|
92
|
-
super().__init__(name="percentage_width")
|
93
|
-
self.percentage:float = percentage
|
94
|
-
self.keep_autoresize: bool = keep_autoresize
|
95
|
-
def to_string(self)->str:
|
96
|
-
return f"{super().to_string()}.[{self.percentage},{self.keep_autoresize}]"
|
97
|
-
def evaluate(self, parent_widget, child_widget):
|
98
|
-
return child_widget.rect.width == round(parent_widget.get_content_width() * self.percentage)
|
99
|
-
|
100
|
-
def apply_constraint(self,parent_widget,child_widget):
|
101
|
-
if not self.evaluate(parent_widget,child_widget):
|
102
|
-
if child_widget.autoresize:
|
103
|
-
if self.keep_autoresize:
|
104
|
-
print(f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True")
|
105
|
-
return
|
106
|
-
child_widget.set_autoresize(False)
|
107
|
-
child_widget.set_size(round(parent_widget.get_content_width() * self.percentage) ,child_widget.rect.h)
|
108
|
-
|
109
|
-
|
110
|
-
class ConstraintPercentageHeight(Constraint):
|
111
|
-
def __init__(self,percentage:float,keep_autoresize:bool=True):
|
112
|
-
super().__init__(name="percentage_height")
|
113
|
-
self.percentage:float = percentage
|
114
|
-
self.keep_autoresize: bool = keep_autoresize
|
115
|
-
|
116
|
-
def evaluate(self, parent_widget, child_widget):
|
117
|
-
return child_widget.rect.height == round(parent_widget.get_content_height() * self.percentage)
|
118
|
-
|
119
|
-
def apply_constraint(self,parent_widget,child_widget):
|
120
|
-
if not self.evaluate(parent_widget,child_widget):
|
121
|
-
if child_widget.autoresize:
|
122
|
-
if self.keep_autoresize:
|
123
|
-
print(f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True")
|
124
|
-
return
|
125
|
-
child_widget.set_autoresize(False)
|
126
|
-
child_widget.set_size(child_widget.rect.w,round(parent_widget.get_content_height() * self.percentage))
|
127
|
-
|
128
|
-
class ConstraintHeight(Constraint):
|
129
|
-
def __init__(self,height:float):
|
130
|
-
if height < 0 :
|
131
|
-
raise ValueError("height can't be negative")
|
132
|
-
super().__init__(name="height")
|
133
|
-
self.height = height
|
134
|
-
|
135
|
-
def to_string(self)->str:
|
136
|
-
return f"{super().to_string()}.({self.height})"
|
137
|
-
|
138
|
-
def evaluate(self, parent_widget, child_widget):
|
139
|
-
return child_widget.rect.height == self.height
|
140
|
-
|
141
|
-
def apply_constraint(self,parent_widget,child_widget):
|
142
|
-
if not self.evaluate(parent_widget,child_widget):
|
143
|
-
child_widget.set_size(child_widget.rect.w,self.height)
|
144
|
-
|
145
|
-
class ConstraintWidth(Constraint):
|
146
|
-
def __init__(self,width:float):
|
147
|
-
if width < 0 :
|
148
|
-
raise ValueError("width can't be negative")
|
149
|
-
super().__init__(name="width")
|
150
|
-
self.width = width
|
151
|
-
|
152
|
-
def to_string(self)->str:
|
153
|
-
return f"{super().to_string()}.({self.width})"
|
154
|
-
|
155
|
-
def evaluate(self, parent_widget, child_widget):
|
156
|
-
return child_widget.rect.width == self.width
|
157
|
-
|
158
|
-
def apply_constraint(self,parent_widget,child_widget):
|
159
|
-
if not self.evaluate(parent_widget,child_widget):
|
160
|
-
child_widget.set_size(self.width,child_widget.rect.h)
|
161
|
-
|
162
|
-
|
163
|
-
class ConstraintAspectRatio(Constraint):
|
164
|
-
def __init__(self,ratio:int|float=1):
|
165
|
-
super().__init__(name="aspect_ratio")
|
166
|
-
if isinstance(ratio, float|int):
|
167
|
-
self.ratio = ratio
|
168
|
-
elif isinstance(ratio,Widget):
|
169
|
-
self.ratio = ratio.rect.w / ratio.rect.h
|
170
|
-
else:
|
171
|
-
raise TypeError(f"Ratio must be float or Widget")
|
172
|
-
def evaluate(self, parent_widget,child_widget):
|
173
|
-
return self.ratio == child_widget.rect.w / child_widget.rect.h
|
174
|
-
|
175
|
-
def apply_constraint(self,parent_widget,child_widget):
|
176
|
-
if not self.evaluate(parent_widget,child_widget):
|
177
|
-
return # TODO
|
178
|
-
|
179
|
-
class ConstraintAnchorBottom(Constraint):
|
180
|
-
def __init__(self):
|
181
|
-
super().__init__(name="anchor_bottom")
|
182
|
-
|
183
|
-
def evaluate(self, parent_widget,child_widget):
|
184
|
-
return child_widget.rect.bottom == parent_widget.rect.bottom
|
185
|
-
|
186
|
-
def apply_constraint(self,parent_widget,child_widget):
|
187
|
-
if not self.evaluate(parent_widget,child_widget):
|
188
|
-
child_widget.set_y(parent_widget.get_content_bottom() - child_widget.rect.h)
|
189
|
-
|
190
|
-
|
191
|
-
class ConstraintAnchorTopRight(Constraint):
|
192
|
-
def __init__(self):
|
193
|
-
super().__init__(name="anchor_topright")
|
194
|
-
|
195
|
-
def evaluate(self, parent_widget,child_widget):
|
196
|
-
return child_widget.rect.topright == parent_widget.rect.topright
|
197
|
-
|
198
|
-
def apply_constraint(self,parent_widget,child_widget):
|
199
|
-
if not self.evaluate(parent_widget,child_widget):
|
200
|
-
child_widget.set_position(parent_widget.get_content_right()-child_widget.rect.w, parent_widget.get_content_top())
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
batFramework/gui/frame.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import batFramework as bf
|
2
|
-
from .shape import Shape
|
3
|
-
import pygame
|
4
|
-
|
5
|
-
|
6
|
-
class Frame(Shape):
|
7
|
-
def __init__(self,width:float,height:float):
|
8
|
-
super().__init__(width,height)
|
9
|
-
self.set_debug_color("magenta")
|
10
|
-
|
11
|
-
def to_string_id(self)->str:
|
12
|
-
return "Frame"
|
13
|
-
|
14
|
-
def children_modified(self)->None:
|
15
|
-
print(self.children)
|
16
|
-
self.set_size(
|
17
|
-
*self.inflate_rect_by_padding(self.rect.unionall(list(c.rect for c in self.children))).size
|
18
|
-
)
|
19
|
-
super().children_modified()
|
batFramework/particles.py
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
import batFramework as bf
|
2
|
-
import pygame
|
3
|
-
from pygame.math import Vector2
|
4
|
-
|
5
|
-
|
6
|
-
class Particle:
|
7
|
-
def __init__(
|
8
|
-
self,
|
9
|
-
start_pos: tuple[float, float],
|
10
|
-
start_vel: tuple[float, float],
|
11
|
-
duration=1000,
|
12
|
-
color=None,
|
13
|
-
size = (4,4)
|
14
|
-
):
|
15
|
-
self.rect = pygame.FRect(*start_pos, 0, 0)
|
16
|
-
self.surface = pygame.Surface(size).convert()
|
17
|
-
if color:
|
18
|
-
self.surface.fill(color)
|
19
|
-
self.velocity = Vector2(*start_vel)
|
20
|
-
self.start_time = pygame.time.get_ticks()
|
21
|
-
self.duration = duration
|
22
|
-
self.dead = False
|
23
|
-
self.progression = 0
|
24
|
-
self.z_depth = 1
|
25
|
-
|
26
|
-
def update(self, dt):
|
27
|
-
if self.dead:
|
28
|
-
return
|
29
|
-
elapsed_time = pygame.time.get_ticks() - self.start_time
|
30
|
-
self.progression = elapsed_time / self.duration
|
31
|
-
self.dead = elapsed_time >= self.duration
|
32
|
-
self.rect.center += self.velocity * dt
|
33
|
-
self.update_surface()
|
34
|
-
|
35
|
-
def kill(self):
|
36
|
-
self.dead = True
|
37
|
-
|
38
|
-
def update_surface(self):
|
39
|
-
self.surface.set_alpha(255 - int(self.progression * 255))
|
40
|
-
|
41
|
-
|
42
|
-
class ParticleManager(bf.Entity):
|
43
|
-
def __init__(self) -> None:
|
44
|
-
super().__init__(size=bf.const.RESOLUTION)
|
45
|
-
self.particles: list[Particle] = []
|
46
|
-
|
47
|
-
def get_bounding_box(self):
|
48
|
-
for particle in self.particles:
|
49
|
-
yield particle.rect
|
50
|
-
|
51
|
-
def add_particle(self, particle_class=Particle, **kwargs):
|
52
|
-
self.particles.append(particle_class(**kwargs))
|
53
|
-
|
54
|
-
|
55
|
-
def clear(self):
|
56
|
-
self.particles = []
|
57
|
-
|
58
|
-
|
59
|
-
def update(self, dt: float):
|
60
|
-
particles_to_remove = []
|
61
|
-
for particle in self.particles:
|
62
|
-
particle.update(dt)
|
63
|
-
if particle.dead:
|
64
|
-
particles_to_remove.append(particle)
|
65
|
-
for p in particles_to_remove:
|
66
|
-
self.particles.remove(p)
|
67
|
-
|
68
|
-
def draw(self, camera) -> bool:
|
69
|
-
camera.surface.fblits(
|
70
|
-
[
|
71
|
-
(
|
72
|
-
p.surface,
|
73
|
-
tuple(round(i * self.z_depth) for i in camera.transpose(self.rect).topleft)
|
74
|
-
) for p in self.particles
|
75
|
-
]
|
76
|
-
)
|
77
|
-
return len(self.particles)
|
File without changes
|
@@ -1,53 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: batframework
|
3
|
-
Version: 1.0.8a8
|
4
|
-
Summary: Pygame framework for making games easier.
|
5
|
-
Requires-Python: >=3.11
|
6
|
-
Description-Content-Type: text/markdown
|
7
|
-
Requires-Dist: pygame-ce
|
8
|
-
|
9
|
-
# batFramework
|
10
|
-
|
11
|
-
batFramework is a Python game framework built using Pygame, designed to simplify game development by providing entities, scenes, a scene manager, and various utilities.
|
12
|
-
|
13
|
-
## Purpose and Overview
|
14
|
-
The primary objective of batFramework is to streamline game development by utilizing entities and scenes that hold entities. It employs a manager, which inherits from the scene manager, to handle scenes, propagate events, and manage updates and rendering.
|
15
|
-
|
16
|
-
## Installation and Setup
|
17
|
-
To install batFramework, you can use pip:
|
18
|
-
```pip install batFramework```
|
19
|
-
|
20
|
-
|
21
|
-
The only dependency required is pygame-ce.
|
22
|
-
|
23
|
-
## Usage Instructions
|
24
|
-
To create a basic app using batFramework, here's an example:
|
25
|
-
|
26
|
-
```python
|
27
|
-
import batFramework as bf
|
28
|
-
|
29
|
-
# Initialize the framework
|
30
|
-
bf.init((1280, 720), window_title="My Amazing Program")
|
31
|
-
|
32
|
-
# Create a manager and a scene
|
33
|
-
bf.Manager(bf.Scene("main")).run()
|
34
|
-
```
|
35
|
-
In practice, users can inherit bf.Scene to create their own scenes, adding specific behaviors, entities, etc.
|
36
|
-
|
37
|
-
## Features and Functionalities
|
38
|
-
|
39
|
-
- Scene management for organizing game components
|
40
|
-
- Cutscene support to facilitate storytelling sequences
|
41
|
-
- Audio management for music and sound effects with volume control
|
42
|
-
- Entity, sprite, and animated sprite support
|
43
|
-
- Utility modules such as time management and easingAnimation
|
44
|
-
|
45
|
-
Users can leverage these functionalities to build games efficiently using batFramework.
|
46
|
-
|
47
|
-
For more detailed usage and examples, please refer to the documentation or codebase.
|
48
|
-
|
49
|
-
|
50
|
-
# License
|
51
|
-
MIT License
|
52
|
-
|
53
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
batFramework/__init__.py,sha256=MLVXC2ymkO3k8LdCgB6TbahgJfhxk4GKAbmndmEgZS4,2146
|
2
|
-
batFramework/action.py,sha256=Phk6-q2P-XyV2GVlXPpxyje0due4fIrKnhI1_4anfjI,7600
|
3
|
-
batFramework/actionContainer.py,sha256=K9dIgG559ckxzRB3t-lpON4dFTcM2mcKZfsf4bhuJ1k,1092
|
4
|
-
batFramework/animatedSprite.py,sha256=kJPKrTOfkbQu2uYDziIEop1z6-gjBwZxkC1Rxd_vBwE,3992
|
5
|
-
batFramework/audioManager.py,sha256=5UsDPy4zsDO7Va1y1kM4lSpEJXU95o9F01E-Sts3osg,2546
|
6
|
-
batFramework/camera.py,sha256=wt4TyWTgQmQElBVeFI7ONzNI75r0FKtB3KmNH00GeFM,4322
|
7
|
-
batFramework/constants.py,sha256=FSyEYLxdAb3JaXA11sAwZBfAImedASohpFcd_7qnG0I,2075
|
8
|
-
batFramework/cutscene.py,sha256=5aiIQeWGmvHCb-N3vjmwxhE4dCXv3iZRFHiexSNxCXM,3650
|
9
|
-
batFramework/cutsceneBlocks.py,sha256=1gmof0jKJ8SqE-RoErm6n1A0JJ4Ang9Q30xEZnW9NaI,5123
|
10
|
-
batFramework/debugger.py,sha256=gh5kOUmGr4t-BFXA17tImid4nzxUqrhsUhE_JV9srNg,1671
|
11
|
-
batFramework/dynamicEntity.py,sha256=REIqH0jnfX6yUThoQNkQrsG0390TR6C5la1h2MAioYk,665
|
12
|
-
batFramework/easing.py,sha256=vGkk7FDPj27X7NCJXALCEyVKDbpXXebWYtMvxkbhOh0,2217
|
13
|
-
batFramework/entity.py,sha256=Tw4_PIA_sY8fhbj9TjE6wPcDTrZZX_Tj7l8oKquqe8U,3178
|
14
|
-
batFramework/manager.py,sha256=LdiQVyuPQE23jwO4EjR4zqDymxtRmthUJ7VE7RIEDpU,1583
|
15
|
-
batFramework/particles.py,sha256=PX8zSqOS1gyDloGAz3fAlrto51lWMUpBXDIM152EYWc,2172
|
16
|
-
batFramework/scene.py,sha256=KM1e53ZfPvuJoSGQZaEl_IouWRYCbFq0QOYTuXYCr-E,7324
|
17
|
-
batFramework/sceneManager.py,sha256=sFkQbfMuR19M4duvCf0SOxSY7MkMrkmiiKh72-tC1nI,5743
|
18
|
-
batFramework/stateMachine.py,sha256=_er9_dcm6MLmlTjXTVm175eqZ9puaKb31PFmNPRhcSU,1338
|
19
|
-
batFramework/time.py,sha256=iGV9mxUFrdXsvm4fJ1faX-VYNsOH7DX2N_aXsDRHhmM,2403
|
20
|
-
batFramework/transition.py,sha256=wmL1Mgg_xopzeDbEPJyAmllLB2BCRJZtuMOR7Mez480,4873
|
21
|
-
batFramework/transitionManager.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
-
batFramework/triggerZone.py,sha256=ikOOlJT1KIND0MO2xiilCHuKlb1eQhkCMEhZTi1btsI,586
|
23
|
-
batFramework/utils.py,sha256=EUB3bMldWTYFVZxcJk5_7XAWcEz080P7PT5ZtkO5TAQ,6164
|
24
|
-
batFramework/gui/__init__.py,sha256=azu5HpC8Q9kupythU5GN5blt7K9oH55oXlOeXsIw1Mw,391
|
25
|
-
batFramework/gui/button.py,sha256=05RMQ20P5npgU9QmiT8v6abJhnhjqRgYbpZGaQXr6Bg,2703
|
26
|
-
batFramework/gui/constraints.py,sha256=pUTNwJqI2Tu57l8ZeQXVXg3b5F5t3aR4Us-CD5qXwnM,7544
|
27
|
-
batFramework/gui/container.py,sha256=XAkPZ0BOVXxzxWP5mKDF_MjYPPPAmUBY-J5zIadO0wQ,1480
|
28
|
-
batFramework/gui/debugger.py,sha256=JORHcSYQQCZ0tDzjnNQvDSOOjZVwEQLeqlr8e6xk2RI,1379
|
29
|
-
batFramework/gui/frame.py,sha256=zjHwbQT1fpRuvNgfBGZhMO_GdMEWqExa5dNlN9kUnUM,514
|
30
|
-
batFramework/gui/image.py,sha256=goOcPntsJeTb3LR7avzi4cXfYHwyGb0KXYttbCiE6fA,777
|
31
|
-
batFramework/gui/indicator.py,sha256=OgqDFsi2HCfbSzVjHkHO_shmo4q4ro3wfd0LWSLTJeQ,957
|
32
|
-
batFramework/gui/interactiveWidget.py,sha256=rRElxI1eFkvOeTfTaA6f8kVTOswOD-DFLAJDUCAI_Yk,641
|
33
|
-
batFramework/gui/label.py,sha256=EO1J5zPVe1skHz-KVqXKBZVKug8UVJUCXyHnvdRDuig,3586
|
34
|
-
batFramework/gui/layout.py,sha256=HyVhYTy1AQacALg6XMY5aX5lj7WY__HCCh8sTSBXwgI,3210
|
35
|
-
batFramework/gui/root.py,sha256=mhlu8ohqq8N-8q__ugv_tGRgPv-1jIHXBFezMFZ4mUM,1763
|
36
|
-
batFramework/gui/shape.py,sha256=CYaD0BdCiuGJO_tS2pALfKPlNGaGRNPzvy-Lk08_R8g,2490
|
37
|
-
batFramework/gui/toggle.py,sha256=jAeEyQXA893gDBUmjN7aoGgfsVln5RTODpSFB4LxwTY,2020
|
38
|
-
batFramework/gui/widget.py,sha256=1PkxThmet8nI5rvSDE6-iPtD_DsZkk-OxriZHbBZaFc,10509
|
39
|
-
batframework-1.0.8a8.dist-info/METADATA,sha256=5bEry2ZJ0j3qgR_eOW9-JmYTInWo72i2dQxnnYPV07s,1713
|
40
|
-
batframework-1.0.8a8.dist-info/WHEEL,sha256=5Mi1sN9lKoFv_gxcPtisEVrJZihrm_beibeg5R6xb4I,91
|
41
|
-
batframework-1.0.8a8.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
|
42
|
-
batframework-1.0.8a8.dist-info/RECORD,,
|
File without changes
|
File without changes
|