batframework 1.0.8a11__tar.gz → 1.0.8a13__tar.gz
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-1.0.8a11/src/batframework.egg-info → batframework-1.0.8a13}/PKG-INFO +1 -1
- {batframework-1.0.8a11 → batframework-1.0.8a13}/pyproject.toml +1 -1
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/__init__.py +3 -2
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/animatedSprite.py +3 -51
- batframework-1.0.8a13/src/batFramework/animation.py +52 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/character.py +2 -2
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/label.py +0 -1
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/layout.py +2 -2
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/templates/character.py +5 -6
- {batframework-1.0.8a11 → batframework-1.0.8a13/src/batframework.egg-info}/PKG-INFO +1 -1
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batframework.egg-info/SOURCES.txt +1 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/LICENCE +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/README.md +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/setup.cfg +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/action.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/actionContainer.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/audioManager.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/camera.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/constants.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/cutscene.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/cutsceneBlocks.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/dynamicEntity.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/easingController.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/entity.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/enums.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/fontManager.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/__init__.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/button.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/clickableWidget.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/constraints/__init__.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/constraints/constraints.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/container.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/debugger.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/dialogueBox.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/draggableWidget.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/image.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/indicator.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/interactiveWidget.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/meter.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/radioButton.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/root.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/shape.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/slider.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/style.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/styleManager.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/textInput.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/toggle.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/widget.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/manager.py +4 -4
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/object.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/particle.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/renderGroup.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/resourceManager.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/scene.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/sceneManager.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/scrollingSprite.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/sprite.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/stateMachine.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/templates/__init__.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/templates/states.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/tileset.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/time.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/transition.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/triggerZone.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/utils.py +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batframework.egg-info/dependency_links.txt +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batframework.egg-info/requires.txt +0 -0
- {batframework-1.0.8a11 → batframework-1.0.8a13}/src/batframework.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "batframework"
|
7
|
-
version = "1.0.
|
7
|
+
version = "1.0.8a13"
|
8
8
|
description = "Pygame framework for making games easier."
|
9
9
|
readme = "README.md"
|
10
10
|
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
|
@@ -24,7 +24,8 @@ from .dynamicEntity import DynamicEntity
|
|
24
24
|
from .sprite import Sprite
|
25
25
|
from .scrollingSprite import ScrollingSprite
|
26
26
|
from .particle import *
|
27
|
-
from .
|
27
|
+
from .animation import Animation
|
28
|
+
from .animatedSprite import AnimatedSprite
|
28
29
|
from .character import Character
|
29
30
|
from .stateMachine import State, StateMachine
|
30
31
|
from .scene import Scene
|
@@ -43,7 +44,7 @@ def init_screen(resolution: tuple[int, int], flags: int = 0, vsync: int = 0):
|
|
43
44
|
const.RESOLUTION, const.FLAGS, vsync=const.VSYNC
|
44
45
|
)
|
45
46
|
print(
|
46
|
-
f"Window : {resolution[0]}x{resolution[1]}
|
47
|
+
f"Window : {resolution[0]}x{resolution[1]}"
|
47
48
|
)
|
48
49
|
|
49
50
|
|
@@ -1,59 +1,11 @@
|
|
1
1
|
import batFramework as bf
|
2
2
|
import pygame
|
3
3
|
from typing import List, Dict, Tuple, Union, Optional, Self
|
4
|
-
|
5
|
-
|
6
|
-
def search_index(target: int, lst: List[int]) -> int:
|
7
|
-
cumulative_sum = 0
|
8
|
-
for index, value in enumerate(lst):
|
9
|
-
cumulative_sum += value
|
10
|
-
if cumulative_sum >= target:
|
11
|
-
return index
|
12
|
-
return -1
|
13
|
-
|
14
|
-
|
15
|
-
class Animation:
|
16
|
-
def __init__(
|
17
|
-
self,
|
18
|
-
name: str
|
19
|
-
) -> None:
|
20
|
-
self.name = name
|
21
|
-
self.frames: list[pygame.Surface] = []
|
22
|
-
self.frames_flipX : list[pygame.Surface] = []
|
23
|
-
self.duration_list = []
|
24
|
-
self.duration_list_length = 1
|
25
|
-
|
26
|
-
def from_surface(self,surface:pygame.Surface,size : Tuple[int,int])->Self:
|
27
|
-
self.frames : List[pygame.Surface] = list(bf.utils.split_surface(surface, size).values())
|
28
|
-
self.frames_flipX : List[pygame.Surface] = list(bf.utils.split_surface(surface, size,func=lambda s : pygame.transform.flip(s,True,False)).values())
|
29
|
-
return self
|
30
|
-
|
31
|
-
def __repr__(self):
|
32
|
-
return f"Animation({self.name})"
|
33
|
-
|
34
|
-
def counter_to_frame(self, counter: Union[float, int]) -> int:
|
35
|
-
if not self.frames :
|
36
|
-
raise ValueError("Animation has no frames")
|
37
|
-
return search_index(
|
38
|
-
int(counter % self.duration_list_length), self.duration_list
|
39
|
-
)
|
40
|
-
|
41
|
-
def get_frame(self, counter: Union[float, int], flip: bool) -> pygame.Surface:
|
42
|
-
i = self.counter_to_frame(counter)
|
43
|
-
return self.frames_flipX[i] if flip else self.frames[i]
|
44
|
-
|
45
|
-
def set_duration_list(self, duration_list: Union[List[int], int]) -> Self:
|
46
|
-
if isinstance(duration_list, int):
|
47
|
-
duration_list = [duration_list] * len(self.frames)
|
48
|
-
if len(duration_list) != len(self.frames):
|
49
|
-
raise ValueError("duration_list should have values for all frames")
|
50
|
-
self.duration_list = duration_list
|
51
|
-
self.duration_list_length = sum(self.duration_list)
|
52
|
-
return self
|
4
|
+
from .animation import Animation
|
53
5
|
|
54
6
|
class AnimatedSprite(bf.Entity):
|
55
|
-
def __init__(self, size: Optional[Tuple[int, int]] = None) -> None:
|
56
|
-
super().__init__(size, no_surface=True)
|
7
|
+
def __init__(self, size: Optional[Tuple[int, int]] = None,*args,**kwargs) -> None:
|
8
|
+
super().__init__(size, no_surface=True,*args,**kwargs)
|
57
9
|
self.float_counter: float = 0
|
58
10
|
self.animations: Dict[str, Animation] = {}
|
59
11
|
self.current_state: Optional[Animation] = None
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import pygame
|
2
|
+
import batFramework as bf
|
3
|
+
from typing import List, Dict, Tuple, Union, Optional, Self
|
4
|
+
|
5
|
+
|
6
|
+
def search_index(target: int, lst: List[int]) -> int:
|
7
|
+
cumulative_sum = 0
|
8
|
+
for index, value in enumerate(lst):
|
9
|
+
cumulative_sum += value
|
10
|
+
if cumulative_sum >= target:
|
11
|
+
return index
|
12
|
+
return -1
|
13
|
+
|
14
|
+
|
15
|
+
class Animation:
|
16
|
+
def __init__(
|
17
|
+
self,
|
18
|
+
name: str
|
19
|
+
) -> None:
|
20
|
+
self.name = name
|
21
|
+
self.frames: list[pygame.Surface] = []
|
22
|
+
self.frames_flipX : list[pygame.Surface] = []
|
23
|
+
self.duration_list = []
|
24
|
+
self.duration_list_length = 1
|
25
|
+
|
26
|
+
def from_surface(self,surface:pygame.Surface,size : Tuple[int,int])->Self:
|
27
|
+
self.frames : List[pygame.Surface] = list(bf.utils.split_surface(surface, size).values())
|
28
|
+
self.frames_flipX : List[pygame.Surface] = list(bf.utils.split_surface(surface, size,func=lambda s : pygame.transform.flip(s,True,False)).values())
|
29
|
+
return self
|
30
|
+
|
31
|
+
def __repr__(self):
|
32
|
+
return f"Animation({self.name})"
|
33
|
+
|
34
|
+
def counter_to_frame(self, counter: Union[float, int]) -> int:
|
35
|
+
if not self.frames :
|
36
|
+
raise ValueError("Animation has no frames")
|
37
|
+
return search_index(
|
38
|
+
int(counter % self.duration_list_length), self.duration_list
|
39
|
+
)
|
40
|
+
|
41
|
+
def get_frame(self, counter: Union[float, int], flip: bool) -> pygame.Surface:
|
42
|
+
i = self.counter_to_frame(counter)
|
43
|
+
return self.frames_flipX[i] if flip else self.frames[i]
|
44
|
+
|
45
|
+
def set_duration_list(self, duration_list: Union[List[int], int]) -> Self:
|
46
|
+
if isinstance(duration_list, int):
|
47
|
+
duration_list = [duration_list] * len(self.frames)
|
48
|
+
if len(duration_list) != len(self.frames):
|
49
|
+
raise ValueError("duration_list should have values for all frames")
|
50
|
+
self.duration_list = duration_list
|
51
|
+
self.duration_list_length = sum(self.duration_list)
|
52
|
+
return self
|
@@ -4,8 +4,8 @@ from .animatedSprite import AnimatedSprite
|
|
4
4
|
from .dynamicEntity import DynamicEntity
|
5
5
|
|
6
6
|
class Character(AnimatedSprite,DynamicEntity):
|
7
|
-
def __init__(self) -> None:
|
8
|
-
super().__init__()
|
7
|
+
def __init__(self,*args,**kwargs) -> None:
|
8
|
+
super().__init__(*args,**kwargs)
|
9
9
|
self.state_machine = bf.StateMachine(self)
|
10
10
|
self.do_setup_animations()
|
11
11
|
self.do_setup_states()
|
@@ -197,7 +197,6 @@ class Label(Shape):
|
|
197
197
|
self.text_rect.size = self._get_text_rect_required_size()
|
198
198
|
res = self.inflate_rect_by_padding((0, 0, *self.text_rect.size)).size
|
199
199
|
|
200
|
-
return res
|
201
200
|
return res[0] if self.autoresize_w else self.rect.w, (
|
202
201
|
res[1] if self.autoresize_h else self.rect.h
|
203
202
|
)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import batFramework as bf
|
2
2
|
from .widget import Widget
|
3
3
|
from .constraints.constraints import *
|
4
|
-
from typing import Self, TYPE_CHECKING
|
5
|
-
from abc import ABC
|
4
|
+
from typing import Self, TYPE_CHECKING
|
5
|
+
from abc import ABC
|
6
6
|
import pygame
|
7
7
|
|
8
8
|
if TYPE_CHECKING:
|
@@ -3,8 +3,8 @@ import pygame
|
|
3
3
|
from .states import *
|
4
4
|
|
5
5
|
class Platform2DCharacter(bf.Character):
|
6
|
-
def __init__(self):
|
7
|
-
super().__init__()
|
6
|
+
def __init__(self,*args,**kwargs):
|
7
|
+
super().__init__(*args,**kwargs)
|
8
8
|
self.actions = bf.ActionContainer(
|
9
9
|
*bf.DirectionalKeyControls(),
|
10
10
|
bf.Action("jump").add_key_control(pygame.K_SPACE).set_holding()
|
@@ -18,8 +18,6 @@ class Platform2DCharacter(bf.Character):
|
|
18
18
|
self.friction = 0.7
|
19
19
|
self.gravity = 300
|
20
20
|
self.terminal_velocity = 1000
|
21
|
-
self.state_machine.set_state("idle")
|
22
|
-
|
23
21
|
|
24
22
|
def do_setup_animations(self):
|
25
23
|
self.add_animation(bf.Animation("idle"))
|
@@ -33,7 +31,8 @@ class Platform2DCharacter(bf.Character):
|
|
33
31
|
self.state_machine.add_state(Platform2DRun())
|
34
32
|
self.state_machine.add_state(Platform2DJump())
|
35
33
|
self.state_machine.add_state(Platform2DFall())
|
36
|
-
|
34
|
+
self.state_machine.set_state("idle")
|
35
|
+
|
37
36
|
|
38
37
|
|
39
38
|
def do_reset_actions(self) -> None:
|
@@ -41,4 +40,4 @@ class Platform2DCharacter(bf.Character):
|
|
41
40
|
|
42
41
|
def do_process_actions(self, event: pygame.Event) -> None:
|
43
42
|
self.actions.process_event(event)
|
44
|
-
|
43
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/constraints/__init__.py
RENAMED
File without changes
|
{batframework-1.0.8a11 → batframework-1.0.8a13}/src/batFramework/gui/constraints/constraints.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -77,8 +77,6 @@ class Manager(bf.SceneManager):
|
|
77
77
|
):
|
78
78
|
bf.const.set_resolution((event.w, event.h))
|
79
79
|
# update
|
80
|
-
dt = self._clock.tick(bf.const.FPS) / 1000
|
81
|
-
# dt = min(dt, 0.02) dirty fix for dt being too high when window not focused for a long time
|
82
80
|
self._timeManager.update(dt)
|
83
81
|
self._cutsceneManager.update(dt)
|
84
82
|
self.update(dt)
|
@@ -86,6 +84,8 @@ class Manager(bf.SceneManager):
|
|
86
84
|
self._screen.fill((0, 0, 0))
|
87
85
|
self.draw(self._screen)
|
88
86
|
pygame.display.flip()
|
87
|
+
dt = self._clock.tick(bf.const.FPS) / 1000
|
88
|
+
# dt = min(dt, 0.02) dirty fix for dt being too high when window not focused for a long time
|
89
89
|
await asyncio.sleep(0)
|
90
90
|
pygame.quit()
|
91
91
|
|
@@ -109,8 +109,6 @@ class Manager(bf.SceneManager):
|
|
109
109
|
):
|
110
110
|
bf.const.set_resolution((event.w, event.h))
|
111
111
|
# update
|
112
|
-
dt = self._clock.tick(bf.const.FPS) / 1000
|
113
|
-
# dt = min(dt, 0.02) dirty fix for dt being too high when window not focused for a long time
|
114
112
|
self._timeManager.update(dt)
|
115
113
|
self._cutsceneManager.update(dt)
|
116
114
|
self.update(dt)
|
@@ -118,4 +116,6 @@ class Manager(bf.SceneManager):
|
|
118
116
|
self._screen.fill((0, 0, 0))
|
119
117
|
self.draw(self._screen)
|
120
118
|
pygame.display.flip()
|
119
|
+
dt = self._clock.tick(bf.const.FPS) / 1000
|
120
|
+
# dt = min(dt, 0.02) dirty fix for dt being too high when window not focused for a long time
|
121
121
|
pygame.quit()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{batframework-1.0.8a11 → batframework-1.0.8a13}/src/batframework.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|