PlayPy 0.3.0__tar.gz → 0.4.0__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.
- {playpy-0.3.0 → playpy-0.4.0}/PKG-INFO +108 -9
- playpy-0.3.0/src/PlayPy.egg-info/PKG-INFO → playpy-0.4.0/README.md +106 -19
- {playpy-0.3.0 → playpy-0.4.0}/pyproject.toml +2 -2
- playpy-0.3.0/README.md → playpy-0.4.0/src/PlayPy.egg-info/PKG-INFO +118 -7
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/__init__.py +607 -492
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/builtin/__init__.py +10 -6
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/builtin/components.py +2 -2
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/builtin/effects.py +9 -8
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/builtin/elements.py +1 -1
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/builtin/events.py +18 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/core/__init__.py +17 -4
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/core/elements.py +0 -1
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/core/resources.py +17 -4
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/core/state.py +232 -28
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/core/workspace.py +238 -65
- {playpy-0.3.0 → playpy-0.4.0}/LICENSE.txt +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/setup.cfg +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/PlayPy.egg-info/SOURCES.txt +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/PlayPy.egg-info/dependency_links.txt +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/PlayPy.egg-info/requires.txt +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/PlayPy.egg-info/top_level.txt +0 -0
- {playpy-0.3.0 → playpy-0.4.0}/src/playpy/data/default_icon.ppm +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PlayPy
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: PlayPy is a lightweight Python library for creating
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
|
|
5
5
|
Author-email: angel <angyv2861@gmail.com>
|
|
6
6
|
Requires-Python: >=3.14
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
@@ -10,7 +10,7 @@ Requires-Dist: pygame-ce>=2.5.6
|
|
|
10
10
|
Requires-Dist: colorama>=0.4.6
|
|
11
11
|
Dynamic: license-file
|
|
12
12
|
|
|
13
|
-
# PlayPy (0.
|
|
13
|
+
# PlayPy (0.4.0)
|
|
14
14
|
|
|
15
15
|
PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
|
|
16
16
|
|
|
@@ -49,6 +49,7 @@ Key methods:
|
|
|
49
49
|
```python
|
|
50
50
|
ws.run()
|
|
51
51
|
ws.quit()
|
|
52
|
+
ws.wait(seconds)
|
|
52
53
|
|
|
53
54
|
ws.queue_scene_change(scene)
|
|
54
55
|
ws.queue_scene_push(scene)
|
|
@@ -74,26 +75,30 @@ handle.disconnect()
|
|
|
74
75
|
|
|
75
76
|
to remotely pop the scoped scene.
|
|
76
77
|
|
|
78
|
+
The scoped scene will automatically be disconnected if not disconnected manually.
|
|
79
|
+
|
|
77
80
|
---
|
|
78
81
|
|
|
79
82
|
## Layout Values
|
|
80
83
|
|
|
81
84
|
PlayPy uses two rectangle value types:
|
|
82
85
|
|
|
83
|
-
### `FRect
|
|
86
|
+
### `FRect`:
|
|
84
87
|
Relative scale values.
|
|
85
88
|
|
|
86
89
|
```python
|
|
87
90
|
plp.FRect(x, y, w, h)
|
|
88
91
|
```
|
|
89
92
|
|
|
90
|
-
### `Rect
|
|
93
|
+
### `Rect`:
|
|
91
94
|
Absolute pixel offsets.
|
|
92
95
|
|
|
93
96
|
```python
|
|
94
97
|
plp.Rect(x, y, w, h)
|
|
95
98
|
```
|
|
96
99
|
|
|
100
|
+
---
|
|
101
|
+
|
|
97
102
|
Final element rectangle:
|
|
98
103
|
|
|
99
104
|
```text
|
|
@@ -103,15 +108,45 @@ Final element rectangle:
|
|
|
103
108
|
Helpers:
|
|
104
109
|
|
|
105
110
|
```python
|
|
106
|
-
plp.empty_rect()
|
|
107
|
-
plp.empty_frect()
|
|
108
|
-
plp.full_screen_rect()
|
|
111
|
+
plp.empty_rect() -> Rect(0, 0, 0, 0)
|
|
112
|
+
plp.empty_frect() -> FRect(0, 0, 0, 0)
|
|
113
|
+
plp.full_screen_rect() -> (FRect(0, 0, 1, 1), Rect(0, 0, 0, 0))
|
|
109
114
|
```
|
|
110
115
|
|
|
111
116
|
Rect types are iterable and support multiple constructor overloads.
|
|
112
117
|
|
|
113
118
|
---
|
|
114
119
|
|
|
120
|
+
## Assets
|
|
121
|
+
|
|
122
|
+
Assets are reusable wrappers around external files such as images, animations, and sounds.
|
|
123
|
+
|
|
124
|
+
PlayPy assets load lazily: they store the path when created, then load the underlying pygame resource when needed. You can also call `load()` ahead of time to preload an asset and reduce latency during gameplay.
|
|
125
|
+
|
|
126
|
+
### Sprites and Animations
|
|
127
|
+
|
|
128
|
+
`Sprite`s load and store images. Initialize them by passing in a path. (`Path` or `str` object)
|
|
129
|
+
|
|
130
|
+
`Animation`s store multiple `Sprite`s and allow for changing of animation settings (FPS, loop, etc.)
|
|
131
|
+
Pass in either sprite paths (`Path` or `str` object), or `Sprite`s themselves.
|
|
132
|
+
|
|
133
|
+
### Sounds
|
|
134
|
+
|
|
135
|
+
`Sound`s load and store user-imported sounds from sound files. Initialize them by passing in a path. (`Path` or `str` object)
|
|
136
|
+
|
|
137
|
+
Useful methods:
|
|
138
|
+
```python
|
|
139
|
+
sound = plp.Sound("my_awesome_sound.wav")
|
|
140
|
+
|
|
141
|
+
sound.load()
|
|
142
|
+
sound.play(loop_amt=3, maxtime=10, fade_ms=500)
|
|
143
|
+
sound.stop()
|
|
144
|
+
sound.set_volume(.5)
|
|
145
|
+
volume = sound.get_volume()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
115
150
|
# Parenting
|
|
116
151
|
|
|
117
152
|
Any `Element` can contain children.
|
|
@@ -183,6 +218,7 @@ Built-in effects:
|
|
|
183
218
|
- `ButtonGradient`
|
|
184
219
|
- `Outline`
|
|
185
220
|
- `BorderRadius`
|
|
221
|
+
- `VisualLayer`
|
|
186
222
|
|
|
187
223
|
Effects are ordered using `z`.
|
|
188
224
|
|
|
@@ -237,6 +273,14 @@ Access input using:
|
|
|
237
273
|
workspace.input
|
|
238
274
|
```
|
|
239
275
|
|
|
276
|
+
Controller profile changes are tracked on the workspace for the current frame:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
workspace.profile_changes
|
|
280
|
+
workspace.profiles_added
|
|
281
|
+
workspace.profiles_removed
|
|
282
|
+
```
|
|
283
|
+
|
|
240
284
|
Properties:
|
|
241
285
|
|
|
242
286
|
```python
|
|
@@ -252,6 +296,15 @@ mouse_pos
|
|
|
252
296
|
mouse_delta
|
|
253
297
|
mouse_wheel
|
|
254
298
|
|
|
299
|
+
controller_buttons_pressed
|
|
300
|
+
controller_ups
|
|
301
|
+
controller_downs
|
|
302
|
+
|
|
303
|
+
controller_left_sticks
|
|
304
|
+
controller_right_sticks
|
|
305
|
+
controller_left_sticks_deltas
|
|
306
|
+
controller_right_stick_deltas
|
|
307
|
+
|
|
255
308
|
text_input
|
|
256
309
|
|
|
257
310
|
dt
|
|
@@ -269,6 +322,30 @@ key_up()
|
|
|
269
322
|
mousebutton_held()
|
|
270
323
|
mousebutton_down()
|
|
271
324
|
mousebutton_up()
|
|
325
|
+
|
|
326
|
+
controllerbutton_held()
|
|
327
|
+
controllerbutton_down()
|
|
328
|
+
controllerbutton_up()
|
|
329
|
+
|
|
330
|
+
left_stick(profile)
|
|
331
|
+
right_stick(profile)
|
|
332
|
+
left_stick_delta(profile)
|
|
333
|
+
right_stick_delta(profile)
|
|
334
|
+
|
|
335
|
+
input_action_held()
|
|
336
|
+
input_action_down()
|
|
337
|
+
input_action_up()
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Use `InputAction`s for easier keybind compatibility. Any matching key, mouse button, or controller button can trigger the action.
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
keybind = plp.InputAction(
|
|
344
|
+
keys = [plp.Key.SPACE, plp.Key.RETURN],
|
|
345
|
+
mouse_buttons = [plp.MouseButton.LEFT],
|
|
346
|
+
controller_buttons = [plp.ControllerButton.A, plp.ControllerButton.B],
|
|
347
|
+
profiles = [plp.InputProfile.KEYBOARD_MOUSE, plp.InputProfile.CONTROLLER_0]
|
|
348
|
+
)
|
|
272
349
|
```
|
|
273
350
|
|
|
274
351
|
---
|
|
@@ -313,6 +390,10 @@ Decorator helpers create `Event` elements.
|
|
|
313
390
|
|
|
314
391
|
@plp.on_scene_change(target)
|
|
315
392
|
|
|
393
|
+
@plp.on_profile_changed(target)
|
|
394
|
+
@plp.on_profile_added(target)
|
|
395
|
+
@plp.on_profile_removed(target)
|
|
396
|
+
|
|
316
397
|
@plp.create_event(target, condition)
|
|
317
398
|
```
|
|
318
399
|
|
|
@@ -383,7 +464,7 @@ Escape -> revert text
|
|
|
383
464
|
|
|
384
465
|
# Scenes
|
|
385
466
|
|
|
386
|
-
|
|
467
|
+
`Scene`s support lifecycle hooks:
|
|
387
468
|
|
|
388
469
|
```python
|
|
389
470
|
on_enter()
|
|
@@ -411,6 +492,24 @@ scrollable.parent = panel
|
|
|
411
492
|
|
|
412
493
|
---
|
|
413
494
|
|
|
495
|
+
### VisualLayer
|
|
496
|
+
|
|
497
|
+
`VisualLayer`s render `Sprite`s, `Animation`s, colors, and shader-like effects.
|
|
498
|
+
|
|
499
|
+
`VisualLayer` constructor:
|
|
500
|
+
```python
|
|
501
|
+
VisualLayer(
|
|
502
|
+
visual: plp.Sprite | plp.Animation | plp.ColorValue,
|
|
503
|
+
blend_mode: plp.BlendMode = plp.BlendMode.RGB_SUBTRACT,
|
|
504
|
+
scale: plp.FRectValue = (0, 0, 1, 1),
|
|
505
|
+
offset: plp.RectValue = (0, 0, 0, 0),
|
|
506
|
+
z: int = -1_000_000,
|
|
507
|
+
visible: bool = True,
|
|
508
|
+
)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
414
513
|
# Logging
|
|
415
514
|
|
|
416
515
|
PlayPy replaces standard exceptions/logging with a categorized logging system.
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Name: PlayPy
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: PlayPy is a lightweight Python library for creating simple games and interactive applications with ease. It provides a straightforward API for handling graphics, input, and basic game mechanics, making it ideal for beginners and those looking to quickly prototype their ideas.
|
|
5
|
-
Author-email: angel <angyv2861@gmail.com>
|
|
6
|
-
Requires-Python: >=3.14
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
License-File: LICENSE.txt
|
|
9
|
-
Requires-Dist: pygame-ce>=2.5.6
|
|
10
|
-
Requires-Dist: colorama>=0.4.6
|
|
11
|
-
Dynamic: license-file
|
|
12
|
-
|
|
13
|
-
# PlayPy (0.3.0)
|
|
1
|
+
# PlayPy (0.4.0)
|
|
14
2
|
|
|
15
3
|
PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
|
|
16
4
|
|
|
@@ -49,6 +37,7 @@ Key methods:
|
|
|
49
37
|
```python
|
|
50
38
|
ws.run()
|
|
51
39
|
ws.quit()
|
|
40
|
+
ws.wait(seconds)
|
|
52
41
|
|
|
53
42
|
ws.queue_scene_change(scene)
|
|
54
43
|
ws.queue_scene_push(scene)
|
|
@@ -74,26 +63,30 @@ handle.disconnect()
|
|
|
74
63
|
|
|
75
64
|
to remotely pop the scoped scene.
|
|
76
65
|
|
|
66
|
+
The scoped scene will automatically be disconnected if not disconnected manually.
|
|
67
|
+
|
|
77
68
|
---
|
|
78
69
|
|
|
79
70
|
## Layout Values
|
|
80
71
|
|
|
81
72
|
PlayPy uses two rectangle value types:
|
|
82
73
|
|
|
83
|
-
### `FRect
|
|
74
|
+
### `FRect`:
|
|
84
75
|
Relative scale values.
|
|
85
76
|
|
|
86
77
|
```python
|
|
87
78
|
plp.FRect(x, y, w, h)
|
|
88
79
|
```
|
|
89
80
|
|
|
90
|
-
### `Rect
|
|
81
|
+
### `Rect`:
|
|
91
82
|
Absolute pixel offsets.
|
|
92
83
|
|
|
93
84
|
```python
|
|
94
85
|
plp.Rect(x, y, w, h)
|
|
95
86
|
```
|
|
96
87
|
|
|
88
|
+
---
|
|
89
|
+
|
|
97
90
|
Final element rectangle:
|
|
98
91
|
|
|
99
92
|
```text
|
|
@@ -103,15 +96,45 @@ Final element rectangle:
|
|
|
103
96
|
Helpers:
|
|
104
97
|
|
|
105
98
|
```python
|
|
106
|
-
plp.empty_rect()
|
|
107
|
-
plp.empty_frect()
|
|
108
|
-
plp.full_screen_rect()
|
|
99
|
+
plp.empty_rect() -> Rect(0, 0, 0, 0)
|
|
100
|
+
plp.empty_frect() -> FRect(0, 0, 0, 0)
|
|
101
|
+
plp.full_screen_rect() -> (FRect(0, 0, 1, 1), Rect(0, 0, 0, 0))
|
|
109
102
|
```
|
|
110
103
|
|
|
111
104
|
Rect types are iterable and support multiple constructor overloads.
|
|
112
105
|
|
|
113
106
|
---
|
|
114
107
|
|
|
108
|
+
## Assets
|
|
109
|
+
|
|
110
|
+
Assets are reusable wrappers around external files such as images, animations, and sounds.
|
|
111
|
+
|
|
112
|
+
PlayPy assets load lazily: they store the path when created, then load the underlying pygame resource when needed. You can also call `load()` ahead of time to preload an asset and reduce latency during gameplay.
|
|
113
|
+
|
|
114
|
+
### Sprites and Animations
|
|
115
|
+
|
|
116
|
+
`Sprite`s load and store images. Initialize them by passing in a path. (`Path` or `str` object)
|
|
117
|
+
|
|
118
|
+
`Animation`s store multiple `Sprite`s and allow for changing of animation settings (FPS, loop, etc.)
|
|
119
|
+
Pass in either sprite paths (`Path` or `str` object), or `Sprite`s themselves.
|
|
120
|
+
|
|
121
|
+
### Sounds
|
|
122
|
+
|
|
123
|
+
`Sound`s load and store user-imported sounds from sound files. Initialize them by passing in a path. (`Path` or `str` object)
|
|
124
|
+
|
|
125
|
+
Useful methods:
|
|
126
|
+
```python
|
|
127
|
+
sound = plp.Sound("my_awesome_sound.wav")
|
|
128
|
+
|
|
129
|
+
sound.load()
|
|
130
|
+
sound.play(loop_amt=3, maxtime=10, fade_ms=500)
|
|
131
|
+
sound.stop()
|
|
132
|
+
sound.set_volume(.5)
|
|
133
|
+
volume = sound.get_volume()
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
115
138
|
# Parenting
|
|
116
139
|
|
|
117
140
|
Any `Element` can contain children.
|
|
@@ -183,6 +206,7 @@ Built-in effects:
|
|
|
183
206
|
- `ButtonGradient`
|
|
184
207
|
- `Outline`
|
|
185
208
|
- `BorderRadius`
|
|
209
|
+
- `VisualLayer`
|
|
186
210
|
|
|
187
211
|
Effects are ordered using `z`.
|
|
188
212
|
|
|
@@ -237,6 +261,14 @@ Access input using:
|
|
|
237
261
|
workspace.input
|
|
238
262
|
```
|
|
239
263
|
|
|
264
|
+
Controller profile changes are tracked on the workspace for the current frame:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
workspace.profile_changes
|
|
268
|
+
workspace.profiles_added
|
|
269
|
+
workspace.profiles_removed
|
|
270
|
+
```
|
|
271
|
+
|
|
240
272
|
Properties:
|
|
241
273
|
|
|
242
274
|
```python
|
|
@@ -252,6 +284,15 @@ mouse_pos
|
|
|
252
284
|
mouse_delta
|
|
253
285
|
mouse_wheel
|
|
254
286
|
|
|
287
|
+
controller_buttons_pressed
|
|
288
|
+
controller_ups
|
|
289
|
+
controller_downs
|
|
290
|
+
|
|
291
|
+
controller_left_sticks
|
|
292
|
+
controller_right_sticks
|
|
293
|
+
controller_left_sticks_deltas
|
|
294
|
+
controller_right_stick_deltas
|
|
295
|
+
|
|
255
296
|
text_input
|
|
256
297
|
|
|
257
298
|
dt
|
|
@@ -269,6 +310,30 @@ key_up()
|
|
|
269
310
|
mousebutton_held()
|
|
270
311
|
mousebutton_down()
|
|
271
312
|
mousebutton_up()
|
|
313
|
+
|
|
314
|
+
controllerbutton_held()
|
|
315
|
+
controllerbutton_down()
|
|
316
|
+
controllerbutton_up()
|
|
317
|
+
|
|
318
|
+
left_stick(profile)
|
|
319
|
+
right_stick(profile)
|
|
320
|
+
left_stick_delta(profile)
|
|
321
|
+
right_stick_delta(profile)
|
|
322
|
+
|
|
323
|
+
input_action_held()
|
|
324
|
+
input_action_down()
|
|
325
|
+
input_action_up()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Use `InputAction`s for easier keybind compatibility. Any matching key, mouse button, or controller button can trigger the action.
|
|
329
|
+
|
|
330
|
+
```python
|
|
331
|
+
keybind = plp.InputAction(
|
|
332
|
+
keys = [plp.Key.SPACE, plp.Key.RETURN],
|
|
333
|
+
mouse_buttons = [plp.MouseButton.LEFT],
|
|
334
|
+
controller_buttons = [plp.ControllerButton.A, plp.ControllerButton.B],
|
|
335
|
+
profiles = [plp.InputProfile.KEYBOARD_MOUSE, plp.InputProfile.CONTROLLER_0]
|
|
336
|
+
)
|
|
272
337
|
```
|
|
273
338
|
|
|
274
339
|
---
|
|
@@ -313,6 +378,10 @@ Decorator helpers create `Event` elements.
|
|
|
313
378
|
|
|
314
379
|
@plp.on_scene_change(target)
|
|
315
380
|
|
|
381
|
+
@plp.on_profile_changed(target)
|
|
382
|
+
@plp.on_profile_added(target)
|
|
383
|
+
@plp.on_profile_removed(target)
|
|
384
|
+
|
|
316
385
|
@plp.create_event(target, condition)
|
|
317
386
|
```
|
|
318
387
|
|
|
@@ -383,7 +452,7 @@ Escape -> revert text
|
|
|
383
452
|
|
|
384
453
|
# Scenes
|
|
385
454
|
|
|
386
|
-
|
|
455
|
+
`Scene`s support lifecycle hooks:
|
|
387
456
|
|
|
388
457
|
```python
|
|
389
458
|
on_enter()
|
|
@@ -411,6 +480,24 @@ scrollable.parent = panel
|
|
|
411
480
|
|
|
412
481
|
---
|
|
413
482
|
|
|
483
|
+
### VisualLayer
|
|
484
|
+
|
|
485
|
+
`VisualLayer`s render `Sprite`s, `Animation`s, colors, and shader-like effects.
|
|
486
|
+
|
|
487
|
+
`VisualLayer` constructor:
|
|
488
|
+
```python
|
|
489
|
+
VisualLayer(
|
|
490
|
+
visual: plp.Sprite | plp.Animation | plp.ColorValue,
|
|
491
|
+
blend_mode: plp.BlendMode = plp.BlendMode.RGB_SUBTRACT,
|
|
492
|
+
scale: plp.FRectValue = (0, 0, 1, 1),
|
|
493
|
+
offset: plp.RectValue = (0, 0, 0, 0),
|
|
494
|
+
z: int = -1_000_000,
|
|
495
|
+
visible: bool = True,
|
|
496
|
+
)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
414
501
|
# Logging
|
|
415
502
|
|
|
416
503
|
PlayPy replaces standard exceptions/logging with a categorized logging system.
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PlayPy"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "PlayPy is a lightweight Python library for creating
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
11
11
|
dependencies = ["pygame-ce>=2.5.6", "colorama>=0.4.6"]
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PlayPy
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
|
|
5
|
+
Author-email: angel <angyv2861@gmail.com>
|
|
6
|
+
Requires-Python: >=3.14
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE.txt
|
|
9
|
+
Requires-Dist: pygame-ce>=2.5.6
|
|
10
|
+
Requires-Dist: colorama>=0.4.6
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# PlayPy (0.4.0)
|
|
2
14
|
|
|
3
15
|
PlayPy is a lightweight Python library for creating games, tools, and interactive applications using a retained-mode UI and scene system built on top of pygame. It focuses on rapid prototyping, composable rendering, and simple but powerful layout primitives.
|
|
4
16
|
|
|
@@ -37,6 +49,7 @@ Key methods:
|
|
|
37
49
|
```python
|
|
38
50
|
ws.run()
|
|
39
51
|
ws.quit()
|
|
52
|
+
ws.wait(seconds)
|
|
40
53
|
|
|
41
54
|
ws.queue_scene_change(scene)
|
|
42
55
|
ws.queue_scene_push(scene)
|
|
@@ -62,26 +75,30 @@ handle.disconnect()
|
|
|
62
75
|
|
|
63
76
|
to remotely pop the scoped scene.
|
|
64
77
|
|
|
78
|
+
The scoped scene will automatically be disconnected if not disconnected manually.
|
|
79
|
+
|
|
65
80
|
---
|
|
66
81
|
|
|
67
82
|
## Layout Values
|
|
68
83
|
|
|
69
84
|
PlayPy uses two rectangle value types:
|
|
70
85
|
|
|
71
|
-
### `FRect
|
|
86
|
+
### `FRect`:
|
|
72
87
|
Relative scale values.
|
|
73
88
|
|
|
74
89
|
```python
|
|
75
90
|
plp.FRect(x, y, w, h)
|
|
76
91
|
```
|
|
77
92
|
|
|
78
|
-
### `Rect
|
|
93
|
+
### `Rect`:
|
|
79
94
|
Absolute pixel offsets.
|
|
80
95
|
|
|
81
96
|
```python
|
|
82
97
|
plp.Rect(x, y, w, h)
|
|
83
98
|
```
|
|
84
99
|
|
|
100
|
+
---
|
|
101
|
+
|
|
85
102
|
Final element rectangle:
|
|
86
103
|
|
|
87
104
|
```text
|
|
@@ -91,15 +108,45 @@ Final element rectangle:
|
|
|
91
108
|
Helpers:
|
|
92
109
|
|
|
93
110
|
```python
|
|
94
|
-
plp.empty_rect()
|
|
95
|
-
plp.empty_frect()
|
|
96
|
-
plp.full_screen_rect()
|
|
111
|
+
plp.empty_rect() -> Rect(0, 0, 0, 0)
|
|
112
|
+
plp.empty_frect() -> FRect(0, 0, 0, 0)
|
|
113
|
+
plp.full_screen_rect() -> (FRect(0, 0, 1, 1), Rect(0, 0, 0, 0))
|
|
97
114
|
```
|
|
98
115
|
|
|
99
116
|
Rect types are iterable and support multiple constructor overloads.
|
|
100
117
|
|
|
101
118
|
---
|
|
102
119
|
|
|
120
|
+
## Assets
|
|
121
|
+
|
|
122
|
+
Assets are reusable wrappers around external files such as images, animations, and sounds.
|
|
123
|
+
|
|
124
|
+
PlayPy assets load lazily: they store the path when created, then load the underlying pygame resource when needed. You can also call `load()` ahead of time to preload an asset and reduce latency during gameplay.
|
|
125
|
+
|
|
126
|
+
### Sprites and Animations
|
|
127
|
+
|
|
128
|
+
`Sprite`s load and store images. Initialize them by passing in a path. (`Path` or `str` object)
|
|
129
|
+
|
|
130
|
+
`Animation`s store multiple `Sprite`s and allow for changing of animation settings (FPS, loop, etc.)
|
|
131
|
+
Pass in either sprite paths (`Path` or `str` object), or `Sprite`s themselves.
|
|
132
|
+
|
|
133
|
+
### Sounds
|
|
134
|
+
|
|
135
|
+
`Sound`s load and store user-imported sounds from sound files. Initialize them by passing in a path. (`Path` or `str` object)
|
|
136
|
+
|
|
137
|
+
Useful methods:
|
|
138
|
+
```python
|
|
139
|
+
sound = plp.Sound("my_awesome_sound.wav")
|
|
140
|
+
|
|
141
|
+
sound.load()
|
|
142
|
+
sound.play(loop_amt=3, maxtime=10, fade_ms=500)
|
|
143
|
+
sound.stop()
|
|
144
|
+
sound.set_volume(.5)
|
|
145
|
+
volume = sound.get_volume()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
103
150
|
# Parenting
|
|
104
151
|
|
|
105
152
|
Any `Element` can contain children.
|
|
@@ -171,6 +218,7 @@ Built-in effects:
|
|
|
171
218
|
- `ButtonGradient`
|
|
172
219
|
- `Outline`
|
|
173
220
|
- `BorderRadius`
|
|
221
|
+
- `VisualLayer`
|
|
174
222
|
|
|
175
223
|
Effects are ordered using `z`.
|
|
176
224
|
|
|
@@ -225,6 +273,14 @@ Access input using:
|
|
|
225
273
|
workspace.input
|
|
226
274
|
```
|
|
227
275
|
|
|
276
|
+
Controller profile changes are tracked on the workspace for the current frame:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
workspace.profile_changes
|
|
280
|
+
workspace.profiles_added
|
|
281
|
+
workspace.profiles_removed
|
|
282
|
+
```
|
|
283
|
+
|
|
228
284
|
Properties:
|
|
229
285
|
|
|
230
286
|
```python
|
|
@@ -240,6 +296,15 @@ mouse_pos
|
|
|
240
296
|
mouse_delta
|
|
241
297
|
mouse_wheel
|
|
242
298
|
|
|
299
|
+
controller_buttons_pressed
|
|
300
|
+
controller_ups
|
|
301
|
+
controller_downs
|
|
302
|
+
|
|
303
|
+
controller_left_sticks
|
|
304
|
+
controller_right_sticks
|
|
305
|
+
controller_left_sticks_deltas
|
|
306
|
+
controller_right_stick_deltas
|
|
307
|
+
|
|
243
308
|
text_input
|
|
244
309
|
|
|
245
310
|
dt
|
|
@@ -257,6 +322,30 @@ key_up()
|
|
|
257
322
|
mousebutton_held()
|
|
258
323
|
mousebutton_down()
|
|
259
324
|
mousebutton_up()
|
|
325
|
+
|
|
326
|
+
controllerbutton_held()
|
|
327
|
+
controllerbutton_down()
|
|
328
|
+
controllerbutton_up()
|
|
329
|
+
|
|
330
|
+
left_stick(profile)
|
|
331
|
+
right_stick(profile)
|
|
332
|
+
left_stick_delta(profile)
|
|
333
|
+
right_stick_delta(profile)
|
|
334
|
+
|
|
335
|
+
input_action_held()
|
|
336
|
+
input_action_down()
|
|
337
|
+
input_action_up()
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Use `InputAction`s for easier keybind compatibility. Any matching key, mouse button, or controller button can trigger the action.
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
keybind = plp.InputAction(
|
|
344
|
+
keys = [plp.Key.SPACE, plp.Key.RETURN],
|
|
345
|
+
mouse_buttons = [plp.MouseButton.LEFT],
|
|
346
|
+
controller_buttons = [plp.ControllerButton.A, plp.ControllerButton.B],
|
|
347
|
+
profiles = [plp.InputProfile.KEYBOARD_MOUSE, plp.InputProfile.CONTROLLER_0]
|
|
348
|
+
)
|
|
260
349
|
```
|
|
261
350
|
|
|
262
351
|
---
|
|
@@ -301,6 +390,10 @@ Decorator helpers create `Event` elements.
|
|
|
301
390
|
|
|
302
391
|
@plp.on_scene_change(target)
|
|
303
392
|
|
|
393
|
+
@plp.on_profile_changed(target)
|
|
394
|
+
@plp.on_profile_added(target)
|
|
395
|
+
@plp.on_profile_removed(target)
|
|
396
|
+
|
|
304
397
|
@plp.create_event(target, condition)
|
|
305
398
|
```
|
|
306
399
|
|
|
@@ -371,7 +464,7 @@ Escape -> revert text
|
|
|
371
464
|
|
|
372
465
|
# Scenes
|
|
373
466
|
|
|
374
|
-
|
|
467
|
+
`Scene`s support lifecycle hooks:
|
|
375
468
|
|
|
376
469
|
```python
|
|
377
470
|
on_enter()
|
|
@@ -399,6 +492,24 @@ scrollable.parent = panel
|
|
|
399
492
|
|
|
400
493
|
---
|
|
401
494
|
|
|
495
|
+
### VisualLayer
|
|
496
|
+
|
|
497
|
+
`VisualLayer`s render `Sprite`s, `Animation`s, colors, and shader-like effects.
|
|
498
|
+
|
|
499
|
+
`VisualLayer` constructor:
|
|
500
|
+
```python
|
|
501
|
+
VisualLayer(
|
|
502
|
+
visual: plp.Sprite | plp.Animation | plp.ColorValue,
|
|
503
|
+
blend_mode: plp.BlendMode = plp.BlendMode.RGB_SUBTRACT,
|
|
504
|
+
scale: plp.FRectValue = (0, 0, 1, 1),
|
|
505
|
+
offset: plp.RectValue = (0, 0, 0, 0),
|
|
506
|
+
z: int = -1_000_000,
|
|
507
|
+
visible: bool = True,
|
|
508
|
+
)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
402
513
|
# Logging
|
|
403
514
|
|
|
404
515
|
PlayPy replaces standard exceptions/logging with a categorized logging system.
|