saltpaper 0.0.3a0__py3-none-any.whl → 0.0.5a0__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.
- saltpaper/__init__.py +1 -1
- saltpaper/functions/__init__.py +1 -0
- saltpaper/functions/spawn.py +11 -0
- saltpaper/services/assetservice.py +6 -1
- saltpaper/services/displayservice.py +2 -2
- saltpaper/services/inputservice.py +12 -1
- saltpaper/services/layer.py +12 -6
- saltpaper/worldsystem/components/position.py +12 -7
- {saltpaper-0.0.3a0.dist-info → saltpaper-0.0.5a0.dist-info}/METADATA +1 -1
- {saltpaper-0.0.3a0.dist-info → saltpaper-0.0.5a0.dist-info}/RECORD +13 -12
- {saltpaper-0.0.3a0.dist-info → saltpaper-0.0.5a0.dist-info}/WHEEL +0 -0
- {saltpaper-0.0.3a0.dist-info → saltpaper-0.0.5a0.dist-info}/licenses/LICENSE +0 -0
- {saltpaper-0.0.3a0.dist-info → saltpaper-0.0.5a0.dist-info}/top_level.txt +0 -0
saltpaper/__init__.py
CHANGED
saltpaper/functions/__init__.py
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from saltpaper.worldsystem.entity import Entity
|
|
2
|
+
from saltpaper.worldsystem.components import Position, Sprite
|
|
3
|
+
|
|
4
|
+
def make_display_entity(world, layer, position, asset_id) -> Entity:
|
|
5
|
+
|
|
6
|
+
ent = Entity(world)
|
|
7
|
+
position = Position(layer, position)
|
|
8
|
+
sprite = Sprite(asset_id)
|
|
9
|
+
ent.add_many(position, sprite)
|
|
10
|
+
|
|
11
|
+
return ent
|
|
@@ -12,10 +12,12 @@ filetypes = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
class AssetService():
|
|
15
|
-
def __init__(self):
|
|
15
|
+
def __init__(self, assets_folder_path):
|
|
16
16
|
self.cache = {}
|
|
17
17
|
self.roots = []
|
|
18
18
|
|
|
19
|
+
self.set_assets_folder(assets_folder_path)
|
|
20
|
+
|
|
19
21
|
def set_assets_folder(self, path):
|
|
20
22
|
path = Path(path)
|
|
21
23
|
self.roots.append(path)
|
|
@@ -41,6 +43,9 @@ class AssetService():
|
|
|
41
43
|
self.cache[id] = asset
|
|
42
44
|
return asset
|
|
43
45
|
|
|
46
|
+
if id == "image_missing":
|
|
47
|
+
raise FileNotFoundError(f"No /image/missing.png is set")
|
|
48
|
+
|
|
44
49
|
print(
|
|
45
50
|
f"asset not found: '{id}' (type='{kind}', name='{name}'). "
|
|
46
51
|
f"tried locations:" + '\n'.join(searched) + "\n",
|
|
@@ -57,9 +57,9 @@ class DisplayService():
|
|
|
57
57
|
self.layers.append(layer)
|
|
58
58
|
self.refresh_sorting()
|
|
59
59
|
|
|
60
|
-
def add_many_layers(self, layers):
|
|
60
|
+
def add_many_layers(self, layers:list):
|
|
61
61
|
self.layers.extend(layers)
|
|
62
|
-
self.refresh_sorting
|
|
62
|
+
self.refresh_sorting()
|
|
63
63
|
|
|
64
64
|
def remove_layer(self, layer):
|
|
65
65
|
for i, item in enumerate(self.layers):
|
|
@@ -13,6 +13,7 @@ if __name__ == "__main__":
|
|
|
13
13
|
import pygame
|
|
14
14
|
import pygame.locals as pl
|
|
15
15
|
import pygame._sdl2.controller as ctrl
|
|
16
|
+
import pygame._sdl2.video as sdl_video
|
|
16
17
|
|
|
17
18
|
KEY_VALUE_TO_NAME = {
|
|
18
19
|
value: name
|
|
@@ -76,11 +77,21 @@ class Criteria():
|
|
|
76
77
|
return on_held_interval
|
|
77
78
|
|
|
78
79
|
class Event():
|
|
79
|
-
def __init__(
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
triggers: str | list,
|
|
83
|
+
criteria: Callable,
|
|
84
|
+
callback: Callable,
|
|
85
|
+
args: list = None,
|
|
86
|
+
priority: int = 0,
|
|
87
|
+
eat_trigger: bool = False
|
|
88
|
+
):
|
|
80
89
|
self.triggers = triggers if isinstance(triggers, list) else [triggers]
|
|
81
90
|
self.criteria = criteria
|
|
82
91
|
self.callback = callback
|
|
83
92
|
self.args = args if args else []
|
|
93
|
+
self.priority = priority
|
|
94
|
+
self.eat_trigger = eat_trigger
|
|
84
95
|
|
|
85
96
|
|
|
86
97
|
class InputService():
|
saltpaper/services/layer.py
CHANGED
|
@@ -4,18 +4,19 @@ import numpy as np
|
|
|
4
4
|
class Layer:
|
|
5
5
|
def __init__(
|
|
6
6
|
self,
|
|
7
|
-
dimensions,
|
|
8
|
-
render_priority=0,
|
|
9
|
-
tick_priority=0,
|
|
10
|
-
opacity_percent=100,
|
|
11
|
-
surface=None,
|
|
7
|
+
dimensions:tuple[int,int],
|
|
8
|
+
render_priority:int=0,
|
|
9
|
+
tick_priority:int=0,
|
|
10
|
+
opacity_percent:int=100,
|
|
11
|
+
surface:pygame.Surface=None,
|
|
12
|
+
offset:tuple[int,int]=(0,0)
|
|
12
13
|
):
|
|
13
14
|
self.dimensions = dimensions
|
|
14
15
|
self.surface = surface if surface else pygame.Surface(dimensions, pygame.HWSURFACE | pygame.SRCALPHA)
|
|
15
16
|
self.visible = True
|
|
16
17
|
self.ticking = True
|
|
17
18
|
self.opacity_percent = opacity_percent
|
|
18
|
-
self.offset =
|
|
19
|
+
self.offset:tuple[int,int] = offset
|
|
19
20
|
|
|
20
21
|
self.render_priority = render_priority
|
|
21
22
|
self.tick_priority = tick_priority
|
|
@@ -43,6 +44,11 @@ class Layer:
|
|
|
43
44
|
surf.set_alpha(int(self.opacity_percent * 2.55))
|
|
44
45
|
return surf
|
|
45
46
|
|
|
47
|
+
def relative_coords(self, coords):
|
|
48
|
+
x, y = coords
|
|
49
|
+
newcoords = (x - self.offset[0], y - self.offset[1])
|
|
50
|
+
return newcoords
|
|
51
|
+
|
|
46
52
|
|
|
47
53
|
def loopscroll(self, dx, dy, dt=1.0):
|
|
48
54
|
self._loopscroll_accum_x += dx * dt
|
|
@@ -2,24 +2,29 @@ class Position():
|
|
|
2
2
|
def __init__(
|
|
3
3
|
self,
|
|
4
4
|
layer:int=0,
|
|
5
|
-
|
|
6
|
-
y:int=0,
|
|
5
|
+
position:tuple[int,int]=(0,0),
|
|
7
6
|
height:int=0,
|
|
8
7
|
width:int=0
|
|
9
8
|
):
|
|
10
9
|
self.layer = layer
|
|
11
|
-
self.
|
|
12
|
-
self.y = y
|
|
10
|
+
self.position = position
|
|
13
11
|
self.height = height
|
|
14
12
|
self.width = width
|
|
15
13
|
|
|
16
14
|
@property
|
|
17
|
-
def
|
|
18
|
-
return
|
|
15
|
+
def x(self):
|
|
16
|
+
return self.position[0]
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def y(self):
|
|
20
|
+
return self.position[1]
|
|
19
21
|
|
|
20
22
|
def set_layer(self, layer):
|
|
21
23
|
self.layer = layer
|
|
22
24
|
|
|
23
25
|
def move(self, dx, dy):
|
|
24
26
|
self.x += dx
|
|
25
|
-
self.y += dy
|
|
27
|
+
self.y += dy
|
|
28
|
+
|
|
29
|
+
def is_point_inside(self, point):
|
|
30
|
+
x, y = point
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
saltpaper/__init__.py,sha256=
|
|
1
|
+
saltpaper/__init__.py,sha256=LrY78Ej9y8JGqZOdjYKMsydpIYJzZy9AgAMsPG5rTWE,185
|
|
2
2
|
saltpaper/assets/.DS_Store,sha256=7-Z-79uIc0CMx4UUj3sSlYE6KAWyk5qlKRTLRnrq8N8,8196
|
|
3
3
|
saltpaper/assets/talk.wav,sha256=rRmMxGFBFGiU59VqfmhIcwdZfuYdY9fUdkv7Os7S3hU,30624
|
|
4
4
|
saltpaper/assets/fonts/LibertinusMono-Regular.ttf,sha256=q9MJTt9ehi35gD8LH8jgr66CFH2oyxsylV3nqPsIOPA,153120
|
|
@@ -7,23 +7,24 @@ saltpaper/assets/music/catacomb.wav,sha256=Rx3u6xe2YnST9c7KKJ6seF9bG6rJyC683Sc6j
|
|
|
7
7
|
saltpaper/assets/tilemaps/test.aseprite,sha256=ZmWh2Ima2Lha5t4kjgNMsnlCamBNEKUsO547Hhtoa2w,416
|
|
8
8
|
saltpaper/assets/tilemaps/test.png,sha256=Q2LU88aK3DOLHrXBjuT86ZJTP_ckODwo1g5Pe9Jut7g,927
|
|
9
9
|
saltpaper/assets/tilemaps/test.yaml,sha256=8YWZeFfbxKxSK8MnEYxERjJIpSszMzRxp5lzGNl2yYw,220
|
|
10
|
-
saltpaper/functions/__init__.py,sha256=
|
|
10
|
+
saltpaper/functions/__init__.py,sha256=aI9Lkm4SRTeWn40xEh9nfuN-b-jq9ImleO-ky690z8w,92
|
|
11
|
+
saltpaper/functions/spawn.py,sha256=YRvnuEImANzvuB872k5D1VwivG5cfGQEkcbJwmvqHso,330
|
|
11
12
|
saltpaper/functions/test.py,sha256=sNpRCjy1CrMrlHv770RTtN6iDwB3Hq7-rKdKaTi3b8s,323
|
|
12
13
|
saltpaper/functions/vectortools.py,sha256=I2ok4i0kZqGq5YXgY1nLblgA14mnlC53D2BBSHrbsHM,752
|
|
13
14
|
saltpaper/services/__init__.py,sha256=Sseu7zdeaB3InIIcs5DIRFK4hhGBqxwvTQaAQP8ksaw,292
|
|
14
|
-
saltpaper/services/assetservice.py,sha256=
|
|
15
|
-
saltpaper/services/displayservice.py,sha256=
|
|
16
|
-
saltpaper/services/inputservice.py,sha256=
|
|
17
|
-
saltpaper/services/layer.py,sha256=
|
|
15
|
+
saltpaper/services/assetservice.py,sha256=KqVD9UXnDB8JUH4XjTcdRBQkFeSPEcijXiSQHYnAlxw,2133
|
|
16
|
+
saltpaper/services/displayservice.py,sha256=NzBmzuaVMcygNv2HnEJZDU5AqV3I_9giGGybvcu2sgY,2999
|
|
17
|
+
saltpaper/services/inputservice.py,sha256=MRIbdwspCw4hS1zVy2VI7_n2UY0Vp9H6omKZK3yCBnE,5131
|
|
18
|
+
saltpaper/services/layer.py,sha256=eIDzZmt1CwjbApnzGsGkM-rJQ-TXmBF-6ho_hNSCPGc,3339
|
|
18
19
|
saltpaper/services/renderservice.py,sha256=jwhnWoa1a_mHXkoHnK-wREGR0cIBKkGf-pVythHkU1E,1250
|
|
19
20
|
saltpaper/services/stateservice.py,sha256=KviqdOkEgZyOiwadOz1nn5QB4jdHUwbGYf355NcqkhM,287
|
|
20
21
|
saltpaper/worldsystem/entity.py,sha256=bRyFMfHblzMwzo81YshDkDjvpMXZrEVrvWjgXtdlS5c,987
|
|
21
22
|
saltpaper/worldsystem/world.py,sha256=-8ckweO6pcwaLb42PGKPveuuHNeR_o0cVqUDFcEt93w,442
|
|
22
23
|
saltpaper/worldsystem/components/__init__.py,sha256=ZYfSsWkkqC-Dkl9QwAjPBydca7ifBzxEhG9_OOcMgRs,57
|
|
23
|
-
saltpaper/worldsystem/components/position.py,sha256=
|
|
24
|
+
saltpaper/worldsystem/components/position.py,sha256=QIJHVc8r1i0KhBBJdAN1dnlPky_8AWkpRJWLvBrGKo0,618
|
|
24
25
|
saltpaper/worldsystem/components/sprite.py,sha256=pQHkyNNKv_iy33LLbqZlOXTU-dqoPzFX7ojjYMOH_BY,102
|
|
25
|
-
saltpaper-0.0.
|
|
26
|
-
saltpaper-0.0.
|
|
27
|
-
saltpaper-0.0.
|
|
28
|
-
saltpaper-0.0.
|
|
29
|
-
saltpaper-0.0.
|
|
26
|
+
saltpaper-0.0.5a0.dist-info/licenses/LICENSE,sha256=Fh0aFC8RSdix3JzjFyLJ3IuzsD1FfsbGFkyqDj5qvXQ,1075
|
|
27
|
+
saltpaper-0.0.5a0.dist-info/METADATA,sha256=6X29jU0N0cGWwRUshm1uhiiVNMDKsK9bAenhvtuv8u0,646
|
|
28
|
+
saltpaper-0.0.5a0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
29
|
+
saltpaper-0.0.5a0.dist-info/top_level.txt,sha256=JACZnZhYYkgmdSz3T1JXacHS4L0UM6NbeReLoNLu6jw,10
|
|
30
|
+
saltpaper-0.0.5a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|