A Javascript puzzle in which you hack your way out. Brilliant.
http://alexnisnevich.github.io/untrusted/
Untrusted is created by Alex Nisnevich and Greg Shuflin. I’ve made my own solutions below:
Level 01 Cell Block A
for (x = 5; x <= map.getWidth() - 5; x++) { map.placeObject(x, 3, 'block'); map.placeObject(x, map.getHeight() - 10, 'block'); }
Level 02 The Long Way Out
Simply comment out the code:
/* then */
Level 03 Validation Engaged
Just move a wall:
for (y = 10; y <= map.getHeight() - 3; y++) { map.placeObject(5, y, 'block'); map.placeObject(map.getWidth() - 10, y, 'block'); } for (x = 5; x <= map.getWidth() - 5; x++) { map.placeObject(x, 10, 'block'); map.placeObject(x, map.getHeight() - 3, 'block'); }
Level 04 Multiplicity
Add a new exit somewhere handy:
map.placeObject(10, 15, 'exit');
Level 05 Minesweeper
Highlight the mines
map.setSquareColor(x,y, '#fff');
Level 06 Drones 101
Block the drone anywhere
map.placeObject(10, 10, 'block');
Level 07 Colors
Toggle the player color with the phone
var player = map.getPlayer(); if (player.getColor() == '#0f0') { player.setColor('#f00'); } else if (player.getColor() == '#f00') { player.setColor('#ff0'); } else { player.setColor('#0f0'); }
Level 08 Into The Woods
Regenerate forest as you move towards the exit:
generateForest
Level 09 Fording the River
Use your phone to toggle raft direction
map.getPlayer().setPhoneCallback( function() { if (raftDirection == 'up') { raftDirection = 'down'; } else { raftDirection = 'up'; } });
Level 10 Drone Ambush
Attack drones behaviour:
if (me.getY() == 13) {me.move('left')} else {me.move('down')};
Reinforcement drones behaviour:
// nothing
Defence drones behaviour:
if (me.getY() == 13) {me.move('right')} else {me.move('down')};
Level 11 Robot
Get the robot to move
if (me.canMove('right')) me.move('right'); else me.move('down');
Level 12 Robot Nav
use the phone to change direction of the robot at will
if (dir == 0) { me.move('up'); } else if (dir == 1) { me.move('right'); } else if (dir == 2) { me.move('down'); } else if (dir == 3) { me.move('left'); } } }); var dir = 0; map.getPlayer().setPhoneCallback(function () { if (dir == 0) { dir = 1; } else if (dir == 1) { dir = 2; } else if (dir == 2) { dir = 3; } else { dir = 0; } }); map.defineObject('defencedrone', { 'type': 'dynamic', 'symbol': 'D', 'color': 'gray', 'onCollision': function (player, me) { me.giveItemTo(player, 'greenKey'); }, 'behavior': function (me) {
Level 13 Robot Maze
Same as before, use the phone to change direction
if (dir == 0) { me.move('up'); } else if (dir == 1) { me.move('right'); } else if (dir == 2) { me.move('down'); } else if (dir == 3) { me.move('left'); } } }); var dir = 0; map.getPlayer().setPhoneCallback(function () { if (dir == 0) { dir = 1; } else if (dir == 1) { dir = 2; } else if (dir == 2) { dir = 3; } else { dir = 0;
Level 14 Crisps Contest
Why not add a new key while we’re about it?
'greenKey');map.placeObject(25,10,'greenKey'
Level 15 Exceptional Crossing
Use an undefined variable
boom
Level 16 Lasers
Add a new exit somewhere handy:
// using canvas to draw the line var ctx = map.getCanvasContext(); ctx.beginPath(); ctx.strokeStyle = color; ctx.lineWidth = 5; ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); ctx.stroke();
And then use the phone to toggle player color:
player.setPhoneCallback(changeColor); function changeColor() { if (player.getColor()==='red') player.setColor('teal'); else if (player.getColor()==='teal') player.setColor('yellow'); else player.setColor('red'); }
Level 17 Pointers
Ha! this was easy – simply rewrite the portals so that the first portal always takes you to the exit:
var easy = map.getDynamicObjects(); t1 = easy[0]; t2 = easy [167]; t1.setTarget(t2); t2.setTarget(t1);
Level 18 Super Dr Eval Bros
Create a ladder with your phone
var player = map.getPlayer(); map.placeObject(player.getX()+1, player.getY()+1, 'ladder'); } map.defineObject('ladder',{ 'type': 'static', 'symbol': '=', 'impassable': true, 'color': 'brown',}); function empty(){
Level 19 Document Object Madness
Use the arrow keys to get both red and green player symbols in the same element.
Level 20 Boss Fight
Not my code, kudos to DaFrElUf – block the bullets, get the phone and blast the boss.
map.defineObject('wall',{ 'type': 'static', 'symbol': '~', 'impassable': true, 'color': 'white',}); map.defineObject('gun',{ 'type': 'static', 'symbol': '>', 'impassable': true, 'color': 'white',}); for (var x = 1; x < 49; x++){ map.placeObject(x, 9, 'wall'); } for (var y = 5; y < 7; y++){ map.placeObject(0, y, 'gun'); } map.defineObject('bullet2', { 'type': 'dynamic', 'symbol': '-', 'color': 'red', 'interval': 100, 'projectile': true, 'behavior': function (me) {me.move('right');} }); function shoot() { var player = map.getPlayer(); map.placeObject(1, 5, 'bullet2'); map.placeObject(1, 6, 'bullet2'); } map.getPlayer().setPhoneCallback(shoot);
Level 21 End of the Line
Go to Menu > Scripts > objects.js and replace this code:
if (!game.map.finalLevel) { game._callUnexposedMethod(function () { game._moveToNextLevel(); }); }
With this:
game._moveToNextLevel();