Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2014 20:03
Show Gist options
  • Save anonymous/11267653 to your computer and use it in GitHub Desktop.
Save anonymous/11267653 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Apr 24, 2014.
    80 changes: 80 additions & 0 deletions untrusted-lvl18-solution.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    /**********************
    * superDrEvalBros.js *
    **********************
    *
    * You're still here?! Well, Dr. Eval, let's see
    * how well you can operate with one less dimension.
    *
    * Give up now. Unless you have a magic mushroom
    * up your sleeve, it's all over.
    */

    function startLevel(map) {
    var fl = Math.floor;
    var w = map.getWidth();
    var h = map.getHeight();

    map.placePlayer(1, fl(h/2)-1);
    var player = map.getPlayer();

    map.placeObject(w-1, fl(h/2)-1, 'exit');

    for (var x = 0; x < fl(w/2) - 5; x++) {
    for (var y = fl(h/2); y < h; y++) {
    map.placeObject(x, y, 'block');
    }
    }

    for (var x = fl(w/2) + 5; x <= w; x++) {
    for (var y = fl(h/2); y < h; y++) {
    map.placeObject(x, y, 'block');
    }
    }

    function gravity() {
    var x = player.getX();
    var y = player.getY() + 1;

    if (y === map.getHeight() - 2) {
    player.killedBy("gravity");
    }

    if (map.getObjectTypeAt(x,y) === "empty") {
    player.move("down");
    }

    }
    map.startTimer(gravity, 45);

    function jump() {
    }

    map.defineObject('block2', {
    'symbol': '░',
    'color': 'white'
    });

    for (var x = fl(w/2) -5; x <= fl(w/2) + 4; x++) {
    for (var y = fl(h/2); y < h; y++) {
    map.placeObject(x, y, 'block2');
    }
    }

    function N() {
    }

    player.setPhoneCallback(function () {
    var x = player.getX();
    var y = player.getY() + 1;

    if (map.getObjectTypeAt(x,y) !== "empty") {
    jump();
    }
    });
    }

    function validateLevel(map) {
    map.validateExactlyXManyObjects(1, 'exit');
    map.validateExactlyXManyObjects(520, 'block');
    }