Add a terrain autotile kind for 6x4 sheets like TD Plains
Sheets such as "TD - Tileset - Plains" draw an autotile as a 6 x 4 block: a 3 x 3 nine-slice, a vertical and a horizontal strip and a single tile on the left, the inner corners on the right. The floor kind only knew the RPG Maker 2 x 3 layout, so these sheets could not be used as autotiles at all. - New TileKind "terrain" with 16 px tiles in a 6 x 4 block. All 47 neighbour combinations are resolved per quarter, so the renderer, the collision and the palette stay untouched. - Whole tiles are used where the sheet draws them: the 16 side cases, the four single notches and the two diagonal pairs. Hand-drawn strips and single blocks therefore look as drawn. - Only the missing cases are composed, for example an edge with a notch or two notches side by side. They take the side tile and put the notch quarters in. - A notch also takes the quarter above or below from its notch tile when fill would stand there. Tall cliff notches keep their wall. On ground and stones fill meets fill, so nothing changes there. - The label rule for floor and terrain now runs through one notch function. Floor still passes the MZ table test. Not touched: the tile board only refits on open and on Fit. Switching an open tile to a kind with another tile size leaves it small until Fit is pressed. That was the case before. Tests: - ./check.sh: 156 files, 2290 tests, CHECK EXIT 0 (before 2283). - e2e 39,40: ALL PASSED, 90 checks (before 86). 39j checks 47 tiles, pixels of single, notch, pair and composed tiles, and undo to floor. - Counter-checks: without whole notch and pair tiles one unit test and one e2e check fail. Without the taken quarter one of each fails. Originals restored by cmp and rebuilt. - Check sum: 1363 measured by CI plus 4 is 1367, computed only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
32cb5b4ba5
commit
c1a702bc39
6 files changed
+297
-28
No files matched your search
@@ -7,12 +7,13 @@ import { type FrameRect, resolvePicture, type TextureRef } from './texture';
|
||||
* A tile is one picture per animation step, and every picture is a *block* the editor cuts into
|
||||
* quarter tiles. `none` is the plain case: the block is the tile itself and every cell shows it as
|
||||
* it is (#131). `floor` and `wall` are the two autotile blocks of the classic RPG-Maker sheets,
|
||||
* whose quarters are picked by the neighbours – that part is `model/autotile.ts`.
|
||||
* `terrain` the 6 × 4 block of the common top-down sheets; their quarters are picked by the
|
||||
* neighbours – that part is `model/autotile.ts`.
|
||||
*
|
||||
* Everything below counts in *quadrants* – quarter tiles – with (0, 0) at the block's top-left
|
||||
* corner, so all three kinds are drawn the same way: four quarters per tile.
|
||||
* corner, so all kinds are drawn the same way: four quarters per tile.
|
||||
*/
|
||||
export const TILE_KINDS = ['none', 'floor', 'wall'] as const;
|
||||
export const TILE_KINDS = ['none', 'floor', 'wall', 'terrain'] as const;
|
||||
export type TileKind = (typeof TILE_KINDS)[number];
|
||||
|
||||
export const TILE_KIND_KEY = 'kind';
|
||||
@@ -36,11 +37,11 @@ export const TILE_COLLISION_SCALE_MAX = 2;
|
||||
const TILE_PLAYBACKS = ['loop', 'pingpong'] as const;
|
||||
export type TilePlayback = (typeof TILE_PLAYBACKS)[number];
|
||||
|
||||
/** Quadrant columns of a block: one tile for `none`, two for the autotile blocks. */
|
||||
const BLOCK_COLUMNS: Record<TileKind, number> = { none: 2, floor: 4, wall: 4 };
|
||||
/** Quadrant columns of a block: one tile for `none`, two for the RPG-Maker blocks, six for `terrain`. */
|
||||
const BLOCK_COLUMNS: Record<TileKind, number> = { none: 2, floor: 4, wall: 4, terrain: 12 };
|
||||
|
||||
/** Quadrant rows of a block: `none` is one tile tall, `floor` three and `wall` two. */
|
||||
const BLOCK_ROWS: Record<TileKind, number> = { none: 2, floor: 6, wall: 4 };
|
||||
/** Quadrant rows of a block: `none` is one tile tall, `floor` three, `wall` two and `terrain` four. */
|
||||
const BLOCK_ROWS: Record<TileKind, number> = { none: 2, floor: 6, wall: 4, terrain: 8 };
|
||||
|
||||
export function tileKind(asset: TileAsset): TileKind {
|
||||
const value = textOf(asset.props[TILE_KIND_KEY] ?? 'none');
|
||||
|
||||
Reference in new issue
Block a user