SOURCE / PINNED RELEASE
Made of little things.
Napcraft
- Release
- ee47ac6a25df…
- Author-recorded commit
- 410dea87e109…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-52f9e22f5ce
Archive hash verified: 9e6e0cabb18d0d46…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
export const WIDTH = 18,
HEIGHT = 12;
export const MATERIALS = [
{ name: 'Air', color: '#ffffff' },
{ name: 'Meadow', color: '#8ac987' },
{ name: 'Pebble', color: '#b9a4cd' },
{ name: 'Timber', color: '#dfb277' },
{ name: 'Coral', color: '#f58d92' },
{ name: 'Glacier', color: '#8bd5e5' },
{ name: 'Butter', color: '#f2d58b' },
];
export type World = {
name: string;
blocks: number[];
edits: number;
locked: boolean;
};
export const cell = (x: number, y: number, z: number) =>
x + z * WIDTH + y * WIDTH * WIDTH;
export function top(world: World, x: number, z: number) {
for (let y = HEIGHT - 1; y >= 0; y--)
if (world.blocks[cell(x, y, z)]) return y;
return -1;
}
export function practiceWorld(): World {
const blocks = Array(WIDTH * WIDTH * HEIGHT).fill(0),
put = (x: number, y: number, z: number, b: number) =>
(blocks[cell(x, y, z)] = b);
for (let x = 0; x < 18; x++)
for (let z = 0; z < 18; z++) {
put(x, 0, z, 2);
put(x, 1, z, 2);
put(x, 2, z, x < 2 || z < 2 || x > 15 || z > 15 ? 6 : 1);
if (x > 12 && z < 6) put(x, 3, z, 1);
}
for (const [x, z] of [
[3, 4],
[13, 12],
[5, 14],
]) {
put(x, 3, z, 3);
put(x, 4, z, 3);
for (let dx = -1; dx <= 1; dx++)
for (let dz = -1; dz <= 1; dz++) put(x + dx, 5, z + dz, 1);
put(x, 6, z, 1);
}
for (let x = 8; x <= 11; x++) for (let z = 3; z <= 6; z++) put(x, 3, z, 3);
for (const [x, z] of [
[8, 3],
[11, 3],
[8, 6],
[11, 6],
]) {
put(x, 4, z, 4);
put(x, 5, z, 4);
}
for (let x = 8; x <= 11; x++) for (let z = 3; z <= 6; z++) put(x, 6, z, 5);
return { name: 'Practice island', blocks, edits: 0, locked: false };
}
export type Gardener = { x: number; z: number; color: number; name: string };
export type Peer = Gardener & {
tx: number;
tz: number;
seen: number;
seq: number;
};
export const PLAYER_COLORS = [
'#f07891',
'#75bfe0',
'#b799ed',
'#efba68',
'#85c8a7',
'#ee98ca',
];
