Skip to content

Instantly share code, notes, and snippets.

@seanmcelroy
Created April 8, 2014 03:30
Show Gist options
  • Save seanmcelroy/10087500 to your computer and use it in GitHub Desktop.
Save seanmcelroy/10087500 to your computer and use it in GitHub Desktop.
untrusted-lvl18-solution.js
/**********************
* 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() {
for (var x = 0; x < map.getWidth(); x++) {
for (var y = fl(h/2); y < h; y++) {
map.placeObject(x, y, 'block');
}
}
}
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');
}
@mateutek
Copy link

if(player.atLocation(1, fl(h/2)-1)){

map.defineObject('water', {
    'symbol': '░',
    'color': '#44f',
    'impassable': true
    });
}  
    var x = player.getX()+1;
    var y = player.getY()+1;
    map.placeObject(x, y, 'water');

@jones
Copy link

jones commented Mar 14, 2015

They added a block count check so here's an updated solution.

function jump() {
    map.defineObject('water', {
        'symbol': '░',
        'color': '#44f',
        'impassable': true
    });

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

@dmix
Copy link

dmix commented Jun 6, 2022

an even hackier solution, just overwrite the gravity function lol

}; function gravity() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment