Skip to content

Instantly share code, notes, and snippets.

@Untrusted-Game
Created June 18, 2020 22:53
Show Gist options
  • Select an option

  • Save Untrusted-Game/996c11f65e0a0256d787b681c0bae181 to your computer and use it in GitHub Desktop.

Select an option

Save Untrusted-Game/996c11f65e0a0256d787b681c0bae181 to your computer and use it in GitHub Desktop.

Revisions

  1. Untrusted-Game created this gist Jun 18, 2020.
    51 changes: 51 additions & 0 deletions untrusted-lvl1-solution.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    /*****************
    * cellBlockA.js *
    *****************
    *
    * Good morning, Dr. Eval.
    *
    * It wasn't easy, but I've managed to get your computer down
    * to you. This system might be unfamiliar, but the underlying
    * code is still JavaScript. Just like we predicted.
    *
    * Now, let's get what we came here for and then get you out of
    * here. Easy peasy.
    *
    * I've given you as much access to their code as I could, but
    * it's not perfect. The red background indicates lines that
    * are off-limits from editing.
    *
    * The code currently places blocks in a rectangle surrounding
    * you. All you need to do is make a gap. You don't even need
    * to do anything extra. In fact, you should be doing less.
    */

    function startLevel(map) {
    map.displayChapter('Chapter 1\nBreakout');

    map.placePlayer(7, 5);

    for (y = 3; y <= map.getHeight() - 10; y++) {
    map.placeObject(5, y, 'block');
    map.placeObject(map.getWidth() - 5, y, 'block');
    }

    for (x = 5; x <= map.getWidth() - 5; x++) {

    map.placeObject(x, map.getHeight() - 10, 'block');
    }

    map.placeObject(15, 12, 'computer');

    map.placeObject(map.getWidth()-7, map.getHeight()-5, 'exit');
    }

    function onExit(map) {
    if (!map.getPlayer().hasItem('computer')) {
    map.writeStatus("Don't forget to pick up the computer!");
    return false;
    } else {
    return true;
    }
    }