@natterjs/assets 0.1.0 → 0.1.1
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.
- package/LICENSE-ASSETS.md +1 -1
- package/README.md +56 -69
- package/package.json +1 -1
package/LICENSE-ASSETS.md
CHANGED
|
@@ -8,7 +8,7 @@ code and falls under the MIT license in `LICENSE`.
|
|
|
8
8
|
|
|
9
9
|
The library is meant to be **CC0 1.0 Universal** (public domain dedication,
|
|
10
10
|
<https://creativecommons.org/publicdomain/zero/1.0/>): free to use, change and pass on, also commercially and
|
|
11
|
-
without attribution. This is how `README.md` („Gedacht als CC0
|
|
11
|
+
without attribution. This is how `README.md`, `CONVENTIONS.md` and the developer notes (`DEVELOPMENT.md`, „Gedacht als CC0“, in the repository) of this package describe it.
|
|
12
12
|
|
|
13
13
|
## Origin
|
|
14
14
|
|
package/README.md
CHANGED
|
@@ -1,92 +1,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @natterjs/assets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Images and sounds for Python games in [Natter](https://natter.wi7.net/) and [CodeNatter](https://codenatter.de): more than 900 PNG sprites in one consistent flat emoji style, two SVG turtle shapes and 14 short sounds, sorted into packs (platformer, space, sea, animals, puzzles, adventure, user interface …) and described in one `catalog.json`. Students write only a name, without uploading files:
|
|
4
4
|
|
|
5
5
|
```python
|
|
6
|
-
|
|
6
|
+
heroine = Actor("heroine_run_1")
|
|
7
7
|
screen.blit("pf_grass_mid", (0, 416))
|
|
8
8
|
sounds.coin.play()
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|---|---|---|---|---|
|
|
15
|
-
| `adventure` | Abenteuer | 82 | 369 KB | `hero_girl_down_1`, `tile_grass`, `adv_chest_closed`, `mon_slime_1` |
|
|
16
|
-
| `animals` | Tiere | 46 | 330 KB | `an_bear`, `an_cat_walk_1`, `pet_cat_happy` |
|
|
17
|
-
| `arcade` | Spielhalle | 71 | 312 KB | `snake_head_right`, `brick_red`, `memory_cat`, `dice_1`, `car_red` |
|
|
18
|
-
| `book` | Teich-Spiel aus dem Buch | 18 | 79 KB | `ente`, `kueken`, `boot`, `seerose`, `teich_hintergrund` |
|
|
19
|
-
| `characters` | Figuren | 38 | 326 KB | `heroine_run_1` … `_8`, `heroine_idle_1`, `boy_run_1`, `enemy_walk_1` |
|
|
20
|
-
| `flyer` | Flieger und Fallendes | 39 | 401 KB | `fl_bird_1`, `fl_pillar_top`, `fall_apple`, `fl_bg_day` |
|
|
21
|
-
| `grid_action` | Raster-Action | 98 | 381 KB | `bomb_1`, `bomb_blast_center`, `td_tower_arrow_1`, `td_road_h`, `farm_carrot_1` … `_4`, `cross_frog_up`, `gem_blue` |
|
|
22
|
-
| `grid_chars` | Rasterfiguren (von oben) | 96 | 274 KB | `robo_down_1`, `fuchs_down_1`, `maus_happy`, `pinguin_idle_1` |
|
|
23
|
-
| `grid_puzzle` | Raster-Rätsel und Brettspiele | 81 | 209 KB | `gp_crate`, `ms_flag`, `pipe_corner_ne`, `chess_king_w`, `num_tile_2048` |
|
|
24
|
-
| `grid_tiles` | Rasterkacheln | 50 | 125 KB | `gt_ice`, `gt_key_red`, `gt_conveyor_up`, `gt_goal` |
|
|
25
|
-
| `kara` | Kara der Marienkäfer | 17 | 75 KB | `kara`, `kara_tree`, `kara_mushroom`, `turtle_top` |
|
|
26
|
-
| `nature` | Natur und Wetter | 51 | 237 KB | `nat_oak`, `nat_cloud_1`, `fruit_apple` |
|
|
27
|
-
| `platformer` | Jump and Run | 89 | 531 KB | `pf_grass_mid`, `pf_coin_1`, `pf_gem_blue_1`, `slug_walk_1`, `pf_bg_day` |
|
|
28
|
-
| `sea` | Meer | 36 | 417 KB | `sea_sailboat`, `sea_fish_1`, `sea_bg` |
|
|
29
|
-
| `space` | Weltraum | 41 | 293 KB | `sp_ship`, `sp_enemy_1`, `sp_explosion_1`, `sp_bg_space` |
|
|
30
|
-
| `turtle` | Turtle (SVG) | 2 | 3 KB | `turtle`, `turtle_side` |
|
|
31
|
-
| `ui` | Spieloberfläche | 81 | 291 KB | `ui_0` … `ui_9`, `ui_heart_full`, `ui_button_blue` |
|
|
32
|
-
| `sounds` | Klänge (WAV) | 14 | 213 KB | `platsch`, `coin`, `jump`, `hit`, `explosion`, `laser`, `win` |
|
|
33
|
-
|
|
34
|
-
Zusammen etwa 4,5 MB. Jedes Paket hat eine `pack.json` (Name, Datei, Schlagwörter, deutsche und englische Beschreibung), die Klänge eine `sounds/sounds.json`.
|
|
35
|
-
|
|
36
|
-
## Katalog
|
|
37
|
-
|
|
38
|
-
`catalog.json` fasst alles in einer Datei zusammen: alle Bilder (Name, Paket, Pfad, Breite × Höhe aus dem PNG-Kopf bzw. dem SVG, Bytes, Schlagwörter, de/en), alle Klänge (mit Länge in Sekunden) und die Bildgruppen, erkannt an der Endung `_<n>`: `animation`, wenn die Beschreibungen von Bildern einer Animation sprechen (`heroine_run`, 8 Bilder), sonst `series` (Varianten wie `dice_1` … `dice_6`).
|
|
11
|
+
Browse every image and sound in the [sprite gallery](https://natter.wi7.net/sprites/).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
39
14
|
|
|
40
15
|
```bash
|
|
41
|
-
npm
|
|
16
|
+
npm install @natterjs/assets
|
|
42
17
|
```
|
|
43
18
|
|
|
44
|
-
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
The package is meant to be served as it is (from jsDelivr, unpkg or a copy of the folder on your own server). `index.js` gives the URLs relative to itself:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { assetsOption, baseUrl, catalogUrl, gametypesUrl } from '@natterjs/assets';
|
|
25
|
+
|
|
26
|
+
assetsOption(); // { baseUrl, catalog: 'catalog.json' }: the whole library
|
|
27
|
+
assetsOption(['space']); // { baseUrl, catalog: 'catalog.json', packs: ['space'] }: only these packs
|
|
28
|
+
baseUrl; // folder of the library, ends with '/'; an image is at baseUrl + 'space/sp_ship.png'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Pass `assetsOption()` as the `assets` option of `createPgzero` or `createKara` from [`@natterjs/web`](https://www.npmjs.com/package/@natterjs/web):
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { createRunner, createPgzero } from 'https://cdn.jsdelivr.net/npm/@natterjs/web@0.1.0/dist/natter-web.js';
|
|
35
|
+
import { assetsOption } from 'https://cdn.jsdelivr.net/npm/@natterjs/assets@0.1.0/index.js';
|
|
36
|
+
|
|
37
|
+
const runner = createRunner();
|
|
38
|
+
const pgz = createPgzero(document.querySelector('#game'), { assets: assetsOption(), lang: 'en' });
|
|
39
|
+
runner.use(pgz);
|
|
40
|
+
await pgz.run(runner, 'ship = Actor("sp_ship", (400, 300))\n\ndef draw():\n screen.clear()\n ship.draw()');
|
|
41
|
+
```
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
When a bundler copies the package files elsewhere, serve the folder yourself and pass its address instead: `{ baseUrl: 'https://example.org/assets/', catalog: 'catalog.json' }`. Without a bundler or npm, use the jsDelivr folder directly as `baseUrl`: `https://cdn.jsdelivr.net/npm/@natterjs/assets@0.1.0/` (always pin a version).
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
### How names map to files
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
| `sea` | Meer | `sea` |
|
|
55
|
-
| `nature` | Natur & Garten | `nature` |
|
|
56
|
-
| `animals` | Tiere | `animals` |
|
|
57
|
-
| `flyer` | Flieger & Fallendes | `flyer` |
|
|
58
|
-
| `arcade` | Arcade | `arcade` |
|
|
59
|
-
| `puzzle` | Rätsel & Brettspiele | `grid_puzzle`, `arcade` |
|
|
60
|
-
| `grid` | Von oben & im Gitter (Kisten schieben, Bomben, Turmverteidigung, Farm, Frosch, Minen, Rohre) | `grid_chars`, `grid_tiles`, `grid_action`, `grid_puzzle` |
|
|
61
|
-
| `adventure` | Abenteuer | `adventure` |
|
|
62
|
-
| `book` | Ente, Kara & Turtle | `book`, `kara`, `turtle` |
|
|
63
|
-
| `ui` | Oberfläche | `ui` |
|
|
47
|
+
- Every image and sound has a unique name across all packs (`^[a-z][a-z0-9_]*$`). The catalog lists it with its pack and file: `heroine_run_1` → `characters/heroine_run_1.png`, `coin` → `sounds/coin.wav`.
|
|
48
|
+
- **Pygame Zero:** `Actor("name")`, `screen.blit("name", …)`, `images.name` and `sounds.name` look the name up in the catalog. The host reads the catalog once and then loads only the files a program names; a string like `"heroine_run_" + str(i)` loads all names starting with `heroine_run_`. A file of the same name in the project's `images/` or `sounds/` folder always wins.
|
|
49
|
+
- **Kara:** the world is drawn with the images of the `kara` pack (`kara`, `kara_up`, `kara_left`, `kara_down`, `kara_tree`, `kara_blueberry`, `kara_mushroom`, `kara_grass` …). Replacing an image of that name in the catalog changes Kara's look; without assets Kara draws vector shapes.
|
|
50
|
+
- **Animations:** frames end in `_<n>`, counted from 1 (`heroine_run_1` … `heroine_run_8`), all frames of one animation have the same size. Characters face right unless the name says `_left`.
|
|
64
51
|
|
|
65
|
-
|
|
52
|
+
### Files
|
|
66
53
|
|
|
67
|
-
|
|
54
|
+
| File | Content |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `catalog.json` | All images (name, pack, path, width × height, bytes, tags, English and German description), all sounds (with length in seconds), the animation groups and the game types |
|
|
57
|
+
| `gametypes.json` | The library sorted by kind of game, with a hand-picked starter set for each |
|
|
58
|
+
| `<pack>/pack.json` | One pack: title, files, tags, descriptions |
|
|
59
|
+
| `<pack>/*.png`, `turtle/*.svg`, `sounds/*.wav` | The images and sounds (about 4.5 MB in total) |
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
- Jedes Blatt entsteht auf einer einfarbigen Magenta-Fläche (`#FF00FF`) ohne Schatten, Boden und Text; `scripts/asset-gen/keyslice.py` stanzt das Magenta zu Transparenz aus, schneidet das Blatt in einzelne, benannte Dateien und richtet Animationsbilder auf eine gemeinsame Leinwand aus (Füße auf gleicher Höhe). Hintergründe (`background`) entstehen ohne Magenta und werden auf 800 × 480 gebracht.
|
|
71
|
-
- Die Texte und Namen jedes Pakets stehen in `<paket>/make.py`, damit es sich neu zeichnen lässt. Jedes Ergebnis wurde auf hellem und dunklem Grund angesehen (Ränder, Stil, Ähnlichkeit zu bekannten Figuren).
|
|
72
|
-
- Die Klänge sind synthetisch (`scripts/gen-sounds.py`, deterministisch).
|
|
61
|
+
Packs: `adventure`, `animals`, `arcade`, `book` (pond game with German names such as `ente`, `kueken`), `characters`, `flyer`, `grid_action`, `grid_chars`, `grid_puzzle`, `grid_tiles`, `kara`, `nature`, `platformer`, `sea`, `space`, `turtle`, `ui`, `sounds`.
|
|
73
62
|
|
|
74
|
-
##
|
|
63
|
+
## Features
|
|
75
64
|
|
|
76
|
-
|
|
65
|
+
- One style for everything, so packs fit together in one game.
|
|
66
|
+
- Animation frames of the same size and aligned (feet at the same height).
|
|
67
|
+
- Every image is listed with size, tags and an English and German description, ready for search and pickers.
|
|
68
|
+
- Loads lazily: hosts fetch the catalog once and only the files a program uses.
|
|
77
69
|
|
|
78
|
-
##
|
|
70
|
+
## Links
|
|
79
71
|
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
72
|
+
- Sprite gallery: <https://natter.wi7.net/sprites/>
|
|
73
|
+
- Website: <https://natter.wi7.net/>, command reference: <https://natter.wi7.net/reference/>
|
|
74
|
+
- Source and issues: <https://github.com/wi-wissen/Natter>
|
|
75
|
+
- [CodeNatter](https://codenatter.de): a browser IDE for learning Python in school, built on Natter.
|
|
84
76
|
|
|
85
|
-
##
|
|
77
|
+
## License
|
|
86
78
|
|
|
87
|
-
1.
|
|
88
|
-
2. Ordner `packages/assets/<paket>/` anlegen, Bilder mit `scripts/asset-gen` erzeugen (siehe dessen README), Prompts in `make.py` festhalten.
|
|
89
|
-
3. `pack.json` schreiben (`pack`, `title.de/en`, `format: "png"`, `assets` mit `name`, `file`, `tags`, `de`, `en`).
|
|
90
|
-
4. Das Paket in `gametypes.json` einer Spielart zuordnen (oder eine neue anlegen, mit Startauswahl).
|
|
91
|
-
5. `npm run assets:catalog`, dann `npx vitest run packages/assets` (prüft Namen, Dateien, Größen, Alphakanal, Katalog, Spielarten).
|
|
92
|
-
6. `npm run sprites` ausführen: das Paket erscheint in der Sprite-Galerie (`docs/sprites/index.html`). CodeNatter übernimmt es mit der nächsten Version von `@natterjs/assets`.
|
|
79
|
+
Images, sounds and the JSON lists are intended as **CC0 1.0** (public domain dedication): free to use, change and share, also commercially and without attribution. They are original work drawn from the project's own prompts and do not imitate existing game, film or brand characters; the sounds are synthesised. Details and origin: `LICENSE-ASSETS.md`. The small `index.js` is code under the MIT license (`LICENSE`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@natterjs/assets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Image and sound library for Natter (Pygame Zero, kara, turtle): about 920 PNG sprites in a flat emoji style, two SVG turtles, 14 sounds and a catalog",
|
|
5
5
|
"license": "(CC0-1.0 AND MIT)",
|
|
6
6
|
"author": "Natter contributors",
|