Skip to content

Commit 870c56c

Browse files
committed
rpg: compact mini tilesets via scripts/pack_tileset.py
scripts/pack_tileset.py reads a v1 map JSON, scans every layer.data for unique non-zero tile ids, slices those cells out of the referenced source PNG, and packs them into a Cols-wide grid (default 8). Emits a new packed PNG and rewrites the JSON's data arrays + tilesets[0].src so ids renumber from 1. Run for the RPG demo: - examples/rpg/Overworld_mini.png (8x1, 7 tiles: grass, water, rock, door, tree, sand, dirt) - examples/rpg/cave_mini.png (8x1, 4 tiles: floor, wall, stairs, water) JSONs updated with the new ids (1..7 / 1..4) and src pointing at the mini PNGs. rpg.bas SPRITE LOAD lines swap to the packed sheets. Why: the IDE map editor's 8x4 tile picker can show the entire used set without paging through 1440-cell Overworld.png, and the tiny sheets are easy to redraw fresh — old mismatched picks like the 'least bad' rock/sand can be replaced one-for-one without touching the maps. Original Overworld.png / cave.png stay in the tree as authoring source. Shooter wasn't packed (already only 3 ids).
1 parent a580ce0 commit 870c56c

4 files changed

Lines changed: 440 additions & 277 deletions

File tree

examples/rpg/level1_cave.json

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"tilesets": [
1414
{
1515
"id": "cave",
16-
"src": "cave.png",
16+
"src": "cave_mini.png",
1717
"cellW": 16,
1818
"cellH": 16,
1919
"tiles": {
20-
"162": {
20+
"2": {
2121
"solid": true,
2222
"kind": "wall"
2323
},
24-
"282": {
24+
"4": {
2525
"solid": true,
2626
"kind": "water"
2727
}
@@ -34,27 +34,27 @@
3434
"type": "tiles",
3535
"tilesetId": "cave",
3636
"data": [
37-
162,
38-
162,
39-
162,
40-
162,
41-
162,
42-
162,
43-
162,
44-
162,
45-
162,
46-
162,
47-
162,
48-
162,
49-
162,
50-
162,
51-
162,
52-
162,
53-
162,
54-
162,
55-
162,
56-
162,
57-
162,
37+
2,
38+
2,
39+
2,
40+
2,
41+
2,
42+
2,
43+
2,
44+
2,
45+
2,
46+
2,
47+
2,
48+
2,
49+
2,
50+
2,
51+
2,
52+
2,
53+
2,
54+
2,
55+
2,
56+
2,
57+
2,
5858
1,
5959
1,
6060
1,
@@ -73,8 +73,8 @@
7373
1,
7474
1,
7575
1,
76-
162,
77-
162,
76+
2,
77+
2,
7878
1,
7979
1,
8080
1,
@@ -93,8 +93,8 @@
9393
1,
9494
1,
9595
1,
96-
162,
97-
162,
96+
2,
97+
2,
9898
1,
9999
1,
100100
1,
@@ -113,8 +113,8 @@
113113
1,
114114
1,
115115
1,
116-
162,
117-
162,
116+
2,
117+
2,
118118
1,
119119
1,
120120
1,
@@ -126,15 +126,15 @@
126126
1,
127127
1,
128128
1,
129-
282,
130-
282,
131-
282,
132-
282,
129+
4,
130+
4,
131+
4,
132+
4,
133133
1,
134134
1,
135135
1,
136-
162,
137-
162,
136+
2,
137+
2,
138138
1,
139139
1,
140140
1,
@@ -146,35 +146,35 @@
146146
1,
147147
1,
148148
1,
149-
282,
150-
282,
151-
282,
152-
282,
149+
4,
150+
4,
151+
4,
152+
4,
153153
1,
154154
1,
155155
1,
156-
162,
157-
162,
156+
2,
157+
2,
158158
1,
159159
1,
160160
1,
161161
1,
162162
1,
163-
162,
164-
162,
165-
162,
166-
162,
163+
2,
164+
2,
165+
2,
166+
2,
167167
1,
168168
1,
169-
282,
170-
282,
171-
282,
172-
282,
169+
4,
170+
4,
171+
4,
172+
4,
173173
1,
174174
1,
175175
1,
176-
162,
177-
162,
176+
2,
177+
2,
178178
1,
179179
1,
180180
1,
@@ -193,8 +193,8 @@
193193
1,
194194
1,
195195
1,
196-
162,
197-
162,
196+
2,
197+
2,
198198
1,
199199
1,
200200
1,
@@ -213,8 +213,8 @@
213213
1,
214214
1,
215215
1,
216-
162,
217-
162,
216+
2,
217+
2,
218218
1,
219219
1,
220220
1,
@@ -233,8 +233,8 @@
233233
1,
234234
1,
235235
1,
236-
162,
237-
162,
236+
2,
237+
2,
238238
1,
239239
1,
240240
1,
@@ -244,7 +244,7 @@
244244
1,
245245
1,
246246
1,
247-
168,
247+
3,
248248
1,
249249
1,
250250
1,
@@ -253,27 +253,27 @@
253253
1,
254254
1,
255255
1,
256-
162,
257-
162,
258-
162,
259-
162,
260-
162,
261-
162,
262-
162,
263-
162,
264-
162,
265-
162,
266-
162,
267-
162,
268-
162,
269-
162,
270-
162,
271-
162,
272-
162,
273-
162,
274-
162,
275-
162,
276-
162
256+
2,
257+
2,
258+
2,
259+
2,
260+
2,
261+
2,
262+
2,
263+
2,
264+
2,
265+
2,
266+
2,
267+
2,
268+
2,
269+
2,
270+
2,
271+
2,
272+
2,
273+
2,
274+
2,
275+
2,
276+
2
277277
]
278278
},
279279
{

0 commit comments

Comments
 (0)