pgzero-plus 0.0.1a1__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.
- pgzero_plus-0.0.1a1/COPYING +165 -0
- pgzero_plus-0.0.1a1/PKG-INFO +259 -0
- pgzero_plus-0.0.1a1/README.md +235 -0
- pgzero_plus-0.0.1a1/pyproject.toml +47 -0
- pgzero_plus-0.0.1a1/setup.cfg +4 -0
- pgzero_plus-0.0.1a1/src/pgzero/__init__.py +41 -0
- pgzero_plus-0.0.1a1/src/pgzero/__main__.py +3 -0
- pgzero_plus-0.0.1a1/src/pgzero/actor.py +597 -0
- pgzero_plus-0.0.1a1/src/pgzero/animation.py +244 -0
- pgzero_plus-0.0.1a1/src/pgzero/builtins.py +45 -0
- pgzero_plus-0.0.1a1/src/pgzero/clock.py +200 -0
- pgzero_plus-0.0.1a1/src/pgzero/constants.py +33 -0
- pgzero_plus-0.0.1a1/src/pgzero/data/icon.png +0 -0
- pgzero_plus-0.0.1a1/src/pgzero/data/joypad.png +0 -0
- pgzero_plus-0.0.1a1/src/pgzero/game.py +573 -0
- pgzero_plus-0.0.1a1/src/pgzero/keyboard.py +67 -0
- pgzero_plus-0.0.1a1/src/pgzero/loaders.py +308 -0
- pgzero_plus-0.0.1a1/src/pgzero/music.py +180 -0
- pgzero_plus-0.0.1a1/src/pgzero/ptext.py +500 -0
- pgzero_plus-0.0.1a1/src/pgzero/rect.py +523 -0
- pgzero_plus-0.0.1a1/src/pgzero/runner.py +233 -0
- pgzero_plus-0.0.1a1/src/pgzero/screen.py +210 -0
- pgzero_plus-0.0.1a1/src/pgzero/soundfmt.py +105 -0
- pgzero_plus-0.0.1a1/src/pgzero/spellcheck.py +173 -0
- pgzero_plus-0.0.1a1/src/pgzero/sprites.py +182 -0
- pgzero_plus-0.0.1a1/src/pgzero/storage.py +191 -0
- pgzero_plus-0.0.1a1/src/pgzero/tilemaps.py +307 -0
- pgzero_plus-0.0.1a1/src/pgzero/tone.py +132 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/PKG-INFO +259 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/SOURCES.txt +52 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/dependency_links.txt +1 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/entry_points.txt +2 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/requires.txt +6 -0
- pgzero_plus-0.0.1a1/src/pgzero_plus.egg-info/top_level.txt +2 -0
- pgzero_plus-0.0.1a1/src/pgzrun.py +34 -0
- pgzero_plus-0.0.1a1/test/test_actor.py +138 -0
- pgzero_plus-0.0.1a1/test/test_actor_features.py +453 -0
- pgzero_plus-0.0.1a1/test/test_animation.py +294 -0
- pgzero_plus-0.0.1a1/test/test_builtins.py +53 -0
- pgzero_plus-0.0.1a1/test/test_event_dispatch.py +41 -0
- pgzero_plus-0.0.1a1/test/test_game_state.py +441 -0
- pgzero_plus-0.0.1a1/test/test_keyboard.py +92 -0
- pgzero_plus-0.0.1a1/test/test_music.py +153 -0
- pgzero_plus-0.0.1a1/test/test_rect_actor.py +99 -0
- pgzero_plus-0.0.1a1/test/test_runner.py +160 -0
- pgzero_plus-0.0.1a1/test/test_screen.py +291 -0
- pgzero_plus-0.0.1a1/test/test_sound_formats.py +61 -0
- pgzero_plus-0.0.1a1/test/test_spellcheck.py +170 -0
- pgzero_plus-0.0.1a1/test/test_sprites.py +309 -0
- pgzero_plus-0.0.1a1/test/test_storage.py +56 -0
- pgzero_plus-0.0.1a1/test/test_tilemaps.py +511 -0
- pgzero_plus-0.0.1a1/test/test_tone.py +31 -0
- pgzero_plus-0.0.1a1/test/test_transform_anchor.py +40 -0
- pgzero_plus-0.0.1a1/test/test_webp_loader.py +27 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pgzero-plus
|
|
3
|
+
Version: 0.0.1a1
|
|
4
|
+
Summary: An enhanced fork of Pygame Zero with additional features for teaching and developing 2D games
|
|
5
|
+
Author-email: Michael D'Argenio <mjdargen@gmail.com>
|
|
6
|
+
License-Expression: LGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/mjdargen/pgzero
|
|
8
|
+
Project-URL: Documentation, https://pygame-zero.readthedocs.io/
|
|
9
|
+
Project-URL: Source, https://github.com/mjdargen/pgzero
|
|
10
|
+
Project-URL: Issues, https://github.com/mjdargen/pgzero/issues
|
|
11
|
+
Keywords: pygame,pgzero,games,education
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Education
|
|
15
|
+
Classifier: Topic :: Games/Entertainment
|
|
16
|
+
Requires-Python: <3.14,>=3.6
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: COPYING
|
|
19
|
+
Requires-Dist: pygame>=2.6.1
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: pyfxr>=0.3.0
|
|
22
|
+
Requires-Dist: importlib-metadata==4.8.3; python_version < "3.8"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# Pygame Zero Plus
|
|
26
|
+
|
|
27
|
+
**Pygame Zero Plus** (`pgzero-plus`) is an independent fork of [Pygame Zero](https://github.com/lordmauve/pgzero), a beginner-friendly Python game development framework that reduces boilerplate code.
|
|
28
|
+
|
|
29
|
+
This fork adds features and quality-of-life improvements for introductory computer science and game design courses while retaining the familiar Pygame Zero API, including `Actor`, `screen`, and `pgzrun`.
|
|
30
|
+
|
|
31
|
+
## What's New
|
|
32
|
+
|
|
33
|
+
- **Enhanced Actors:** Scaling, flipping, opacity, and customizable collision rectangles.
|
|
34
|
+
- **Sprite Animations:** `Sprite` and `SpriteActor` classes for animated sprite sheets.
|
|
35
|
+
- **Tilemaps:** Loading and rendering maps created with [Tiled Map Editor](https://www.mapeditor.org/), including tilesets and tile transformations.
|
|
36
|
+
- **Game Management:** A `Game` object for tracking scores, levels, game states, and restarting games.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
The PyPI distribution is named `pgzero-plus`, but it provides the same `pgzero` Python package and `pgzrun` command as the original Pygame Zero. **Do not install both distributions in the same Python environment.**
|
|
41
|
+
|
|
42
|
+
### Install or Update
|
|
43
|
+
|
|
44
|
+
Once published on PyPI:
|
|
45
|
+
|
|
46
|
+
**Windows:**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install --upgrade pgzero-plus
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**macOS / Linux:**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python3 -m pip install --upgrade pgzero-plus
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Switching from Pygame Zero or an Older Fork
|
|
59
|
+
|
|
60
|
+
If you previously installed `pgzero` or `pgzero-mjd`, uninstall any overlapping distributions before installing Pygame Zero Plus. This also helps repair environments where multiple forks have been installed together.
|
|
61
|
+
|
|
62
|
+
**Windows:**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python -m pip uninstall -y pgzero pgzero-mjd pgzero-plus
|
|
66
|
+
python -m pip install pgzero-plus
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**macOS / Linux:**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 -m pip uninstall -y pgzero pgzero-mjd pgzero-plus
|
|
73
|
+
python3 -m pip install pgzero-plus
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`--force-reinstall` does **not** remove a differently named distribution, so it is not a substitute for uninstalling the original `pgzero` package.
|
|
77
|
+
|
|
78
|
+
### Running Games
|
|
79
|
+
|
|
80
|
+
Pygame Zero Plus supports running games as regular Python scripts, including with the Run button in VS Code.
|
|
81
|
+
|
|
82
|
+
Start your program with:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import pgzrun
|
|
86
|
+
from pgzero.builtins import *
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The explicit `pgzero.builtins` import helps editors such as VS Code (Pylance) recognize names like `Actor` and `screen`.
|
|
90
|
+
|
|
91
|
+
Define your variables and functions, such as `start()`, `draw()`, and `update()`, then end the program with:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
pgzrun.go()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Run the script through your editor or with:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
python game.py
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Alternatively, use the traditional Pygame Zero command:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pgzrun game.py
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
Clone the repository:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git clone https://github.com/mjdargen/pgzero.git
|
|
115
|
+
cd pgzero
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Install the fork in editable mode **and** install all development tools with one command:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
python -m pip install -r requirements-dev.txt
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`requirements-dev.txt` includes `-e .`, which installs the local package and its runtime dependencies. Source changes are available immediately without rebuilding the wheel. If the original `pgzero` is installed in this environment, uninstall it first as described above.
|
|
125
|
+
|
|
126
|
+
### Pre-commit Checks
|
|
127
|
+
|
|
128
|
+
[Pre-commit](https://pre-commit.com/) checks whitespace, file endings, YAML/TOML syntax, merge conflict markers, and accidentally added large files.
|
|
129
|
+
|
|
130
|
+
Activate it **once per clone**, after installing the development dependencies:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python -m pre_commit install
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
It then runs automatically on staged files before each `git commit`. If a hook modifies a file, review it with `git diff`, stage the fix with `git add`, and retry the commit.
|
|
137
|
+
|
|
138
|
+
To check all tracked files manually at any time:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
python -m pre_commit run --all-files
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Using `python -m pre_commit` avoids Windows PATH issues where the `pre-commit` command is not recognized.
|
|
145
|
+
|
|
146
|
+
### Testing
|
|
147
|
+
|
|
148
|
+
Run all tests from the repository root:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
python -m pytest
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For detailed output or one test file:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python -m pytest -v
|
|
158
|
+
python -m pytest test/test_actor.py
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Documentation
|
|
162
|
+
|
|
163
|
+
Documentation is written in [Sphinx](https://www.sphinx-doc.org/) using the `.rst` files in `doc/`. Update these pages when features or behavior change, and add new pages to `doc/index.rst` so they appear in the navigation.
|
|
164
|
+
|
|
165
|
+
Build and preview locally from the repository root:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
python -m sphinx -b html doc doc/_build/html
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
On Windows (PowerShell), open the generated documentation with:
|
|
172
|
+
|
|
173
|
+
```powershell
|
|
174
|
+
start doc/_build/html/index.html
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
On macOS or Linux, open that HTML file in your browser. The Sphinx configuration lives in `doc/conf.py`.
|
|
178
|
+
|
|
179
|
+
Once this repository is connected to [Read the Docs](https://readthedocs.org/), its `.readthedocs.yaml` configuration allows the hosted documentation to rebuild automatically after changes are pushed. GitHub Actions verifies that the documentation builds; Read the Docs hosts and publishes the website.
|
|
180
|
+
|
|
181
|
+
### Automated Checks on GitHub
|
|
182
|
+
|
|
183
|
+
The [Code Checks workflow](https://github.com/mjdargen/pgzero/actions) (`.github/workflows/checks.yml`) runs automatically on pushes to `main` and on pull requests. It runs pre-commit, pytest, Sphinx, the package build, and distribution validation.
|
|
184
|
+
|
|
185
|
+
These checks run **after** a push, so a failing check does not undo the push. Check the Actions page for results and fix any failures before publishing a release.
|
|
186
|
+
|
|
187
|
+
## Building and Verification
|
|
188
|
+
|
|
189
|
+
The automated release workflow builds distributions for publishing, so **manual builds are optional** during everyday development. To check a release locally, run:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
python -m pre_commit run --all-files
|
|
193
|
+
python -m pytest
|
|
194
|
+
python -m sphinx -b html doc doc/_build/html
|
|
195
|
+
python -m build
|
|
196
|
+
python -m twine check --strict dist/*
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The wheel (`.whl`) and source archive (`.tar.gz`) are written to `dist/`. Clear out older distributions from `dist/` before building a new version so you do not accidentally inspect or upload old files.
|
|
200
|
+
|
|
201
|
+
### Verify the Built Wheel
|
|
202
|
+
|
|
203
|
+
Install the built wheel in a **fresh virtual environment** to check the distribution itself instead of your editable development installation. The example filename below is for version `0.1.0`; update it when the version changes.
|
|
204
|
+
|
|
205
|
+
**Windows (PowerShell):**
|
|
206
|
+
|
|
207
|
+
```powershell
|
|
208
|
+
python -m venv .venv-wheel-check
|
|
209
|
+
.\.venv-wheel-check\Scripts\python.exe -m pip install dist/pgzero_plus-0.1.0-py3-none-any.whl
|
|
210
|
+
.\.venv-wheel-check\Scripts\python.exe -m pip check
|
|
211
|
+
.\.venv-wheel-check\Scripts\python.exe -c "import pgzero, pgzrun; print(pgzero.__file__)"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**macOS / Linux:**
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python3 -m venv .venv-wheel-check
|
|
218
|
+
.venv-wheel-check/bin/python -m pip install dist/pgzero_plus-0.1.0-py3-none-any.whl
|
|
219
|
+
.venv-wheel-check/bin/python -m pip check
|
|
220
|
+
.venv-wheel-check/bin/python -c "import pgzero, pgzrun; print(pgzero.__file__)"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Python 3.6 compatibility:** This fork targets Python 3.6 through 3.13, including older Codio environments. The modern build backend does not support building from source on Python 3.6. Before a release, install the **built wheel** in Codio and run a representative game there; passing tests on Python 3.13 does not establish compatibility with Python 3.6.
|
|
224
|
+
|
|
225
|
+
## Publishing Releases
|
|
226
|
+
|
|
227
|
+
GitHub Actions handles publishing through `.github/workflows/release.yml`. A new package is **not** published on every push to `main`; publishing starts only when you push a version tag.
|
|
228
|
+
|
|
229
|
+
### One-time PyPI Setup
|
|
230
|
+
|
|
231
|
+
1. Create a GitHub repository environment named `pypi` under **Settings → Environments**.
|
|
232
|
+
2. Configure [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) for project `pgzero-plus`, GitHub owner `mjdargen`, repository `pgzero`, workflow `release.yml`, and environment `pypi`. For a first release, use a _pending trusted publisher_ if the project has not yet been created on PyPI.
|
|
233
|
+
|
|
234
|
+
This allows GitHub Actions to publish without storing a PyPI API token.
|
|
235
|
+
|
|
236
|
+
### Create a Release
|
|
237
|
+
|
|
238
|
+
1. Set the new `version` in `pyproject.toml`. For example, `version = "0.1.0"`.
|
|
239
|
+
2. Commit and push your changes to `main`, then confirm that **Code Checks** passes on the [Actions page](https://github.com/mjdargen/pgzero/actions).
|
|
240
|
+
3. Create and push a Git tag **matching** that version, with a leading `v`:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
git switch main
|
|
244
|
+
git pull
|
|
245
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
246
|
+
git push origin v0.1.0
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The release workflow verifies the version, runs the checks, builds the wheel and source archive, publishes to PyPI, and creates a GitHub Release with the built files attached. If a check or build fails, publishing stops.
|
|
250
|
+
|
|
251
|
+
For a later release, update the version number and use its matching tag (for example, `0.1.1` and `v0.1.1`). Use patch releases for bug fixes and minor releases for new features. **PyPI does not allow replacing files for an existing published version.**
|
|
252
|
+
|
|
253
|
+
## Credits & License
|
|
254
|
+
|
|
255
|
+
This project is an independent fork of [Pygame Zero](https://github.com/lordmauve/pgzero), originally developed by Daniel Pope and contributors.
|
|
256
|
+
|
|
257
|
+
Original documentation: https://pygame-zero.readthedocs.io/
|
|
258
|
+
|
|
259
|
+
Licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later).
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Pygame Zero Plus
|
|
2
|
+
|
|
3
|
+
**Pygame Zero Plus** (`pgzero-plus`) is an independent fork of [Pygame Zero](https://github.com/lordmauve/pgzero), a beginner-friendly Python game development framework that reduces boilerplate code.
|
|
4
|
+
|
|
5
|
+
This fork adds features and quality-of-life improvements for introductory computer science and game design courses while retaining the familiar Pygame Zero API, including `Actor`, `screen`, and `pgzrun`.
|
|
6
|
+
|
|
7
|
+
## What's New
|
|
8
|
+
|
|
9
|
+
- **Enhanced Actors:** Scaling, flipping, opacity, and customizable collision rectangles.
|
|
10
|
+
- **Sprite Animations:** `Sprite` and `SpriteActor` classes for animated sprite sheets.
|
|
11
|
+
- **Tilemaps:** Loading and rendering maps created with [Tiled Map Editor](https://www.mapeditor.org/), including tilesets and tile transformations.
|
|
12
|
+
- **Game Management:** A `Game` object for tracking scores, levels, game states, and restarting games.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
The PyPI distribution is named `pgzero-plus`, but it provides the same `pgzero` Python package and `pgzrun` command as the original Pygame Zero. **Do not install both distributions in the same Python environment.**
|
|
17
|
+
|
|
18
|
+
### Install or Update
|
|
19
|
+
|
|
20
|
+
Once published on PyPI:
|
|
21
|
+
|
|
22
|
+
**Windows:**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python -m pip install --upgrade pgzero-plus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**macOS / Linux:**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python3 -m pip install --upgrade pgzero-plus
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Switching from Pygame Zero or an Older Fork
|
|
35
|
+
|
|
36
|
+
If you previously installed `pgzero` or `pgzero-mjd`, uninstall any overlapping distributions before installing Pygame Zero Plus. This also helps repair environments where multiple forks have been installed together.
|
|
37
|
+
|
|
38
|
+
**Windows:**
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python -m pip uninstall -y pgzero pgzero-mjd pgzero-plus
|
|
42
|
+
python -m pip install pgzero-plus
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**macOS / Linux:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python3 -m pip uninstall -y pgzero pgzero-mjd pgzero-plus
|
|
49
|
+
python3 -m pip install pgzero-plus
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`--force-reinstall` does **not** remove a differently named distribution, so it is not a substitute for uninstalling the original `pgzero` package.
|
|
53
|
+
|
|
54
|
+
### Running Games
|
|
55
|
+
|
|
56
|
+
Pygame Zero Plus supports running games as regular Python scripts, including with the Run button in VS Code.
|
|
57
|
+
|
|
58
|
+
Start your program with:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import pgzrun
|
|
62
|
+
from pgzero.builtins import *
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The explicit `pgzero.builtins` import helps editors such as VS Code (Pylance) recognize names like `Actor` and `screen`.
|
|
66
|
+
|
|
67
|
+
Define your variables and functions, such as `start()`, `draw()`, and `update()`, then end the program with:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
pgzrun.go()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run the script through your editor or with:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
python game.py
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Alternatively, use the traditional Pygame Zero command:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pgzrun game.py
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
Clone the repository:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/mjdargen/pgzero.git
|
|
91
|
+
cd pgzero
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Install the fork in editable mode **and** install all development tools with one command:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python -m pip install -r requirements-dev.txt
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`requirements-dev.txt` includes `-e .`, which installs the local package and its runtime dependencies. Source changes are available immediately without rebuilding the wheel. If the original `pgzero` is installed in this environment, uninstall it first as described above.
|
|
101
|
+
|
|
102
|
+
### Pre-commit Checks
|
|
103
|
+
|
|
104
|
+
[Pre-commit](https://pre-commit.com/) checks whitespace, file endings, YAML/TOML syntax, merge conflict markers, and accidentally added large files.
|
|
105
|
+
|
|
106
|
+
Activate it **once per clone**, after installing the development dependencies:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
python -m pre_commit install
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
It then runs automatically on staged files before each `git commit`. If a hook modifies a file, review it with `git diff`, stage the fix with `git add`, and retry the commit.
|
|
113
|
+
|
|
114
|
+
To check all tracked files manually at any time:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
python -m pre_commit run --all-files
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Using `python -m pre_commit` avoids Windows PATH issues where the `pre-commit` command is not recognized.
|
|
121
|
+
|
|
122
|
+
### Testing
|
|
123
|
+
|
|
124
|
+
Run all tests from the repository root:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
python -m pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
For detailed output or one test file:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python -m pytest -v
|
|
134
|
+
python -m pytest test/test_actor.py
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Documentation
|
|
138
|
+
|
|
139
|
+
Documentation is written in [Sphinx](https://www.sphinx-doc.org/) using the `.rst` files in `doc/`. Update these pages when features or behavior change, and add new pages to `doc/index.rst` so they appear in the navigation.
|
|
140
|
+
|
|
141
|
+
Build and preview locally from the repository root:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python -m sphinx -b html doc doc/_build/html
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
On Windows (PowerShell), open the generated documentation with:
|
|
148
|
+
|
|
149
|
+
```powershell
|
|
150
|
+
start doc/_build/html/index.html
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
On macOS or Linux, open that HTML file in your browser. The Sphinx configuration lives in `doc/conf.py`.
|
|
154
|
+
|
|
155
|
+
Once this repository is connected to [Read the Docs](https://readthedocs.org/), its `.readthedocs.yaml` configuration allows the hosted documentation to rebuild automatically after changes are pushed. GitHub Actions verifies that the documentation builds; Read the Docs hosts and publishes the website.
|
|
156
|
+
|
|
157
|
+
### Automated Checks on GitHub
|
|
158
|
+
|
|
159
|
+
The [Code Checks workflow](https://github.com/mjdargen/pgzero/actions) (`.github/workflows/checks.yml`) runs automatically on pushes to `main` and on pull requests. It runs pre-commit, pytest, Sphinx, the package build, and distribution validation.
|
|
160
|
+
|
|
161
|
+
These checks run **after** a push, so a failing check does not undo the push. Check the Actions page for results and fix any failures before publishing a release.
|
|
162
|
+
|
|
163
|
+
## Building and Verification
|
|
164
|
+
|
|
165
|
+
The automated release workflow builds distributions for publishing, so **manual builds are optional** during everyday development. To check a release locally, run:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
python -m pre_commit run --all-files
|
|
169
|
+
python -m pytest
|
|
170
|
+
python -m sphinx -b html doc doc/_build/html
|
|
171
|
+
python -m build
|
|
172
|
+
python -m twine check --strict dist/*
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The wheel (`.whl`) and source archive (`.tar.gz`) are written to `dist/`. Clear out older distributions from `dist/` before building a new version so you do not accidentally inspect or upload old files.
|
|
176
|
+
|
|
177
|
+
### Verify the Built Wheel
|
|
178
|
+
|
|
179
|
+
Install the built wheel in a **fresh virtual environment** to check the distribution itself instead of your editable development installation. The example filename below is for version `0.1.0`; update it when the version changes.
|
|
180
|
+
|
|
181
|
+
**Windows (PowerShell):**
|
|
182
|
+
|
|
183
|
+
```powershell
|
|
184
|
+
python -m venv .venv-wheel-check
|
|
185
|
+
.\.venv-wheel-check\Scripts\python.exe -m pip install dist/pgzero_plus-0.1.0-py3-none-any.whl
|
|
186
|
+
.\.venv-wheel-check\Scripts\python.exe -m pip check
|
|
187
|
+
.\.venv-wheel-check\Scripts\python.exe -c "import pgzero, pgzrun; print(pgzero.__file__)"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**macOS / Linux:**
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
python3 -m venv .venv-wheel-check
|
|
194
|
+
.venv-wheel-check/bin/python -m pip install dist/pgzero_plus-0.1.0-py3-none-any.whl
|
|
195
|
+
.venv-wheel-check/bin/python -m pip check
|
|
196
|
+
.venv-wheel-check/bin/python -c "import pgzero, pgzrun; print(pgzero.__file__)"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Python 3.6 compatibility:** This fork targets Python 3.6 through 3.13, including older Codio environments. The modern build backend does not support building from source on Python 3.6. Before a release, install the **built wheel** in Codio and run a representative game there; passing tests on Python 3.13 does not establish compatibility with Python 3.6.
|
|
200
|
+
|
|
201
|
+
## Publishing Releases
|
|
202
|
+
|
|
203
|
+
GitHub Actions handles publishing through `.github/workflows/release.yml`. A new package is **not** published on every push to `main`; publishing starts only when you push a version tag.
|
|
204
|
+
|
|
205
|
+
### One-time PyPI Setup
|
|
206
|
+
|
|
207
|
+
1. Create a GitHub repository environment named `pypi` under **Settings → Environments**.
|
|
208
|
+
2. Configure [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) for project `pgzero-plus`, GitHub owner `mjdargen`, repository `pgzero`, workflow `release.yml`, and environment `pypi`. For a first release, use a _pending trusted publisher_ if the project has not yet been created on PyPI.
|
|
209
|
+
|
|
210
|
+
This allows GitHub Actions to publish without storing a PyPI API token.
|
|
211
|
+
|
|
212
|
+
### Create a Release
|
|
213
|
+
|
|
214
|
+
1. Set the new `version` in `pyproject.toml`. For example, `version = "0.1.0"`.
|
|
215
|
+
2. Commit and push your changes to `main`, then confirm that **Code Checks** passes on the [Actions page](https://github.com/mjdargen/pgzero/actions).
|
|
216
|
+
3. Create and push a Git tag **matching** that version, with a leading `v`:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
git switch main
|
|
220
|
+
git pull
|
|
221
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
222
|
+
git push origin v0.1.0
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The release workflow verifies the version, runs the checks, builds the wheel and source archive, publishes to PyPI, and creates a GitHub Release with the built files attached. If a check or build fails, publishing stops.
|
|
226
|
+
|
|
227
|
+
For a later release, update the version number and use its matching tag (for example, `0.1.1` and `v0.1.1`). Use patch releases for bug fixes and minor releases for new features. **PyPI does not allow replacing files for an existing published version.**
|
|
228
|
+
|
|
229
|
+
## Credits & License
|
|
230
|
+
|
|
231
|
+
This project is an independent fork of [Pygame Zero](https://github.com/lordmauve/pgzero), originally developed by Daniel Pope and contributors.
|
|
232
|
+
|
|
233
|
+
Original documentation: https://pygame-zero.readthedocs.io/
|
|
234
|
+
|
|
235
|
+
Licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later).
|