Files

42 lines
2.4 KiB
JavaScript

// Travel join grid: UR/DR/DL/UL, both ends, and all three neighbouring placements.
// Screw H and V, then belt H; each tries the side, above/below, and E.
// Self-contained, paused and empty. Use --zoom 4 --viewport 2100x1500 --no-light.
money = 50000;
for (let y = 0; y < 460; y++) for (let x = 0; x < 600; x++) {
const i = y * W + x;
setCell(i, EMPTY, 20, 0); bgm[i] = 0;
}
for (let x = 0; x < 600; x++) surfY[x] = 420;
window.JOIN_CASES = [];
for (let row = 0; row < 8; row++) for (let col = 0; col < 9; col++) {
const v = 4 + (row >> 1), end = row & 1, side = end ? 1 : -1;
const slope = v === 4 || v === 6 ? -1 : 1, dy = side * slope;
const vertical = col >= 3 && col < 6, belt = col >= 6, spot = col % 3;
const bx = 34 + col * 12, by = 24 + row * 10;
const nx = bx + (spot === 1 ? 0 : side), ny = by + (spot === 0 ? 0 : dy);
const code = belt ? BP_BELT : BP_SCREW;
const [tx, ty] = SCREW_DIRS[v];
const straight = belt ? (tx > 0 ? 1 : 0) : vertical ? (ty < 0 ? 0 : 2) : (tx > 0 ? 1 : 3);
const diagonalCode = belt ? (slope < 0 ? BP_BELT_UP : BP_BELT_DOWN) : BP_SCREW;
const diagonalV = belt ? (SCREW_DIRS[v][0] > 0 ? 1 : 0) : v;
for (let k = 0; k < 2; k++) placeBlock(diagonalCode, diagonalV, bx - k * side, by - k * dy, true);
for (let k = 0; k < 2; k++) placeBlock(code, straight, nx + (vertical ? 0 : k * side * (spot === 1 ? -1 : 1)), ny + (vertical ? k * dy * (spot === 0 ? -1 : 1) : 0), true);
const joined = endJoin(bx, by, end) >= 0;
const kind = joined ? (ny === by ? (end ? 2 : 4) : nx === bx ? (ny < by ? 1 : 3) : vertical ? 6 : 5) : 0;
JOIN_CASES.push({v, end, bx, by, nx, ny, vertical, code, straight, joined, kind, spot});
}
updateRoof();
window.CAM = [326, 232];
// Labels are part of the scene so screenshots and browser checks use the same layout.
drawBot = () => {
const ctx = R.ctx;
ctx.save(); ctx.font = '12px monospace'; ctx.textBaseline = 'bottom';
for (const j of JOIN_CASES) {
const p = worldToScreenPx(j.bx * BS - 8, j.by * BS - 14);
ctx.fillStyle = '#17222c';
const name = ['UR', 'DR', 'DL', 'UL'][j.v - 4], axis = j.code === BP_BELT ? 'belt' : j.vertical ? 'V' : 'H';
ctx.fillText(`${name} ${['↗','↘','↙','↖'][j.v-4]} ${j.end ? 'R' : 'L'} ${axis} ${j.vertical ? (SCREW_DIRS[j.v][1]<0?'↑':'↓') : (SCREW_DIRS[j.v][0]>0?'→':'←')} ${['row', 'axis', 'diag'][j.spot]}: ${j.joined ? 'JOIN' : 'free'}`, p.x, p.y);
}
ctx.restore();
};