/* @title: Invisible-cow @author: Xhand98 @description: Find the cow in an invisible field @tags: ["puzzle", "funny"] @addedOn: 2026-05-26 */ const player = "p" const cow = "c" const cowbackup = "b" const melody = tune` 89.02077151335311: A4~89.02077151335311, 89.02077151335311: A4~89.02077151335311, 89.02077151335311: C5~89.02077151335311, 89.02077151335311: A4~89.02077151335311, 89.02077151335311, 89.02077151335311: A4~89.02077151335311, 89.02077151335311, 89.02077151335311: A4~89.02077151335311, 89.02077151335311: C5~89.02077151335311, 89.02077151335311, 89.02077151335311: E5~89.02077151335311, 178.04154302670622, 89.02077151335311: F5~89.02077151335311, 89.02077151335311: B4~89.02077151335311, 89.02077151335311, 89.02077151335311: G4~89.02077151335311, 89.02077151335311: F4~89.02077151335311, 89.02077151335311: A4~89.02077151335311 + B4~89.02077151335311 + E5~89.02077151335311, 267.06231454005933, 89.02077151335311: E5~89.02077151335311 + G5~89.02077151335311 + F5~89.02077151335311, 89.02077151335311: F5~89.02077151335311, 89.02077151335311, 89.02077151335311: F5~89.02077151335311, 89.02077151335311: A5~89.02077151335311, 178.04154302670622, 89.02077151335311: F5~89.02077151335311, 89.02077151335311: F5~89.02077151335311 + D5~89.02077151335311 + F4~89.02077151335311 + A4~89.02077151335311, 89.02077151335311: G4~89.02077151335311` const moo = tune` 182.370820668693, 91.1854103343465: B4~91.1854103343465 + A4~91.1854103343465, 91.1854103343465: A4~91.1854103343465, 91.1854103343465: G4~91.1854103343465, 2462.0060790273556` playTune(melody, moo) setLegend( [player, bitmap` 0000000000000000 000.00.00.00.000 00............00 0..............0 00............00 00............00 0..............0 00............00 00............00 0..............0 00............00 00............00 0..............0 00............00 000.00.00.00.000 0000000000000000`], [cow, bitmap` ................ ...00..00....... ..080..080...... .0080000800..... .0111122220..... ..01012020...... ..01022020...... .0288888220..... .028080822000... ..088888201220.. ...000000112100. ...022221112100. ...011122222200. ...01000020020.. ...00....00.00.. ................`], [cowbackup, bitmap` ..2............. ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................`] ) setSolids([]) let level = 0 const levels = [ map` ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ p........b.. ............`, map` p...... ....... ....... ....... ....... .....b. .......`, map` ...... ....p. ...... ...... ...... ...... ...... ...... .b....`, map` ................ ................ p............... ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ................ ............b... ................ ................ ................ ................ ................ ................` ] setMap(levels[level]) setPushables({ [ player ]: [] }) const MoveY = (dy) => { getFirst(player).y += dy} const MoveX = (dx) => { getFirst(player).x += dx} onInput("s", () => {MoveY(1)}) onInput("d", () => {MoveX(1)}) onInput("w", () => {MoveY(-1)}) onInput("a", () => {MoveX(-1)}) let playback let won = false afterInput(() => { const targetNumber = tilesWith(cowbackup).length let p = getFirst(player) let c = getFirst(cowbackup) let dist = Math.abs(p.x - c.x) + Math.abs(p.y - c.y) if (dist <= 5 && won == false) { if (!playback) { playback = playTune(moo, Infinity) } } else { if (playback) { playback.end() playback = null } } // count the number of tiles with goals and boxes const numberCovered = tilesWith(cowbackup, player).length; // if the number of goals is the same as the number of goals covered // all goals are covered and we can go to the next level if (numberCovered === targetNumber) { // increase the current level number level = level + 1; const currentLevel = levels[level]; // make sure the level exists and if so set the map // otherwise, we have finished the last level, there is no level // after the last level if (currentLevel !== undefined) { setMap(currentLevel); } else { won = true addText("You found all the cows!!", { y: 4, color: color`3` }); } } });