Be Excellent To Each Other
https://www.beexcellenttoeachother.com/forum/

JavaScript game
https://www.beexcellenttoeachother.com/forum/viewtopic.php?f=3&t=10043
Page 1 of 1

Author:  Grim... [ Sun Apr 13, 2014 18:00 ]
Post subject:  JavaScript game

http://alexnisnevich.github.io/untrusted/

This is a lovely little game where you have to "hack" the script that runs the page to get to the exit.

Really nicely done.

Author:  GazChap [ Sun Apr 13, 2014 19:50 ]
Post subject:  Re: JavaScript game

That really is really fucking good, isn't it?

Author:  Grim... [ Sun Apr 13, 2014 20:06 ]
Post subject:  Re: JavaScript game

Yeah, clever bastards. Did you get to the end?

Author:  GazChap [ Sun Apr 13, 2014 20:25 ]
Post subject:  Re: JavaScript game

Nah, got a bit bored at the start of chapter 2, but I expect I'll go back to it.

Author:  Grim... [ Sun Apr 13, 2014 22:57 ]
Post subject:  Re: JavaScript game

GazChap wrote:
Nah, got a bit bored at the start of chapter 2, but I expect I'll go back to it.

Only 19 to go!

Author:  Malc [ Sun Apr 13, 2014 23:12 ]
Post subject:  Re: JavaScript game

I'm stuck on the river with the raft.

ZOMG Spoiler! Click here to view!
I am trying to use player.getY(), but it says player is not defined. I used player.getX() on the coloured barrier level, so am a little confused.


Malc

Author:  Grim... [ Sun Apr 13, 2014 23:18 ]
Post subject:  Re: JavaScript game

It's not defined for you like it is on some other levels. Just throw in a
Code:
var player = map.getPlayer();
at the start of your code.

Author:  Mr Dave [ Tue Apr 15, 2014 0:09 ]
Post subject:  Re: JavaScript game

Well, I've got to level 15, which is causing some headscratching.

Be interested to know how people solved the last of the robot mazes.

ZOMG Spoiler! Click here to view!
I just went for a cheap trick of having 4 squares I could stand on which moved it in a certain direction. Hardly advanced AI like they spoke of it the comment.

Author:  Grim... [ Tue Apr 15, 2014 2:09 ]
Post subject:  Re: JavaScript game

That's exactly what I did.
ZOMG Spoiler! Click here to view!
Bound up four squares and used them like a joypad :)


There's a big clue in the level name for 15.

Author:  Mr Dave [ Tue Apr 15, 2014 2:27 ]
Post subject:  Re: JavaScript game

Grim... wrote:
That's exactly what I did.
ZOMG Spoiler! Click here to view!
Bound up four squares and used them like a joypad :)


There's a big clue in the level name for 15.

Yeah, I got it eventually
ZOMG Spoiler! Click here to view!
Bear in mind that doing such a thing isn't even possible in c#. Tried chucking null at it, and blank before posting that. Currently being thwarted by completely useless errors in level 17. I can think of numerous ways of doing it, but can't get any of them to work and the error messages are useless. Similarly my first solution to the maze did require a simple searching AI, but no longer have the javascript knowhow to even create an array

Author:  Grim... [ Tue Apr 15, 2014 9:52 ]
Post subject:  Re: JavaScript game

Yeah, the error handling makes life complicated.

Code:
var myArray = ['foo', 'bar'];
;)

Author:  Mr Dave [ Tue Apr 15, 2014 10:04 ]
Post subject:  Re: JavaScript game

Grim... wrote:
Yeah, the error handling makes life complicated.

Code:
var myArray = ['foo', 'bar'];
;)

Yeah, somewhat tedious if you have a 2D array of visited nodes the size of the maze.

Onto the jumping one now.

Author:  Pod [ Wed Apr 16, 2014 9:09 ]
Post subject:  Re: JavaScript game

I'm stuck on level 9. I don't know javascript so I don't know how to do what I want to do.


ZOMG Spoiler! Click here to view!
I want to bind a callback to the phone so that it moves the raft up one place each time I press the button, or to make it switch it's behaviour method to move towards the exit. But I don't know how to reference the raft object?!

findNearest('raft') (or possibly 'dynamic', looking at the api section?) doesn't seem to be defined on the player or the map.



edit: Also

ZOMG Spoiler! Click here to view!
var player = map.getPlayer();
is already in the scope for the editable bit of level 9? Have they changed it since?

Author:  GazChap [ Wed Apr 16, 2014 9:14 ]
Post subject:  Re: JavaScript game

You don't need to reference the raft object.

ZOMG Spoiler! Click here to view!
There's a variable called raftDirection that tells the raft which direction to move...

Author:  Pod [ Wed Apr 16, 2014 9:17 ]
Post subject:  Re: JavaScript game

I just saw that. I AM A RETARD. I just read it's behaviour as always me.move() and assumed that had it moving towards the player, rather than always moving in a certain direction.

Author:  Pod [ Wed Apr 16, 2014 9:23 ]
Post subject:  Re: JavaScript game

and for level 10: Javascript advice: Why doesn't this work?

ZOMG Spoiler! Click here to view!
Why can't I just change this:

map.defineObject('attackDrone', {
'type': 'dynamic',
'symbol': 'd',
'color': 'red',
'onCollision': function (player) {
player.killedBy('an attack drone');
},
'behavior': function (me) {
moveToward(me, 'player');
}
});

into this:

'behavior': function (me) {
me.onCollision = function(player){};
me['onCollision'] = function(player){};

}

Shouldn't that work? I just want to nop out their lethal attack, basically...
Note: I solved it another way, but I want to know what I'm doing wrong here. The API info seems to suggest what I did is valid?



Anyway, no spoilers for this:

Code:
        'behavior': function (me) {
            me.lol_state = 0
           
            if (me.lol_state == 0)
            {
               me.move('down')
                me.lol_state = 1
            }
         else
            {
               me.move('right')
            }
   
        }

or:

        'behavior': function (me) {
            me.behavior.lol_state = 0
           
            if (me.behavior.lol_state == 0)
            {
               me.move('down')
                me.behavior.lol_state = 1
            }
         else
            {
               me.move('right')
            }
   
        }



This doesn't work, but the few things I know about javascript (e.g. this page) would suggest it should. Infact the second one doesn't move the robot at all for some reason?

So the language we're using here either a) isn't simply javascript pushed through an eval() function or b) they pass in a copy of the robot into the behaviour function each time or c) probably a combo of both

The dirty cheats.

Author:  Pod [ Wed Apr 16, 2014 10:28 ]
Post subject:  Re: JavaScript game

FUCK OFF

I pressed ctrl+4 instead of ctrl + 5.

Author:  MrD [ Fri Apr 18, 2014 5:28 ]
Post subject:  Re: JavaScript game

This game is phenomenally ace.

I think I didn't get into the spirit of the thing for the robot...

ZOMG Spoiler! Click here to view!
me.move(dir);
}
});

var dir = 'left';

a = function () {
if (dir == 'left')
dir = 'up';
else if (dir == 'up')
dir = 'right';
else if (dir == 'right')
dir = 'down';
else if (dir == 'down')
dir = 'left';
}

player.setPhoneCallback(a);

map.defineObject('dave', { 'behavior': function(me) {

--

If the black space lets me put in blank lines, by god that's what I'll do!


I don't have time to figure out the syntax 16 right now but it's looking like:
ZOMG Spoiler! Click here to view!
get list of adjacent cells. iterate: check type of item in cell, if trap, get canvas and draw X on cell.

all traps are now visible.


This is so much better than god damned Carnage Heart it's unreal.

Author:  Mr Dave [ Fri Apr 18, 2014 9:08 ]
Post subject:  Re: JavaScript game

MrD wrote:
ZOMG Spoiler! Click here to view!
get list of adjacent cells. iterate: check type of item in cell, if trap, get canvas and draw X on cell.

all traps are now visible.


ZOMG Spoiler! Click here to view!
I had a similar idea, although it involved moving the teleporters. Won't work - all traps are visible - they have a different symbol. Just some teleporters teleport you onto them. Obvious if you actually follow the code through too.

Author:  Grim... [ Fri Apr 18, 2014 12:57 ]
Post subject:  Re: JavaScript game

I actually lucked through that one when trying something else :)

Author:  Mr Dave [ Fri Apr 18, 2014 13:07 ]
Post subject:  Re: JavaScript game

Grim... wrote:
I actually lucked through that one when trying something else :)

ZOMG Spoiler! Click here to view!
I just did a search for two specific teleporters, one by the player, one by the exit, and linked the player one to the exit one. Before that I tried creating one by the player, but it threw out all kinds of strange error messages.
Neither me nor my boss particularly understood what the comment hint was about, but both came up with broadly similar solutions

Author:  MrD [ Sat Apr 19, 2014 3:47 ]
Post subject:  Re: JavaScript game

Mr Dave wrote:
MrD wrote:
ZOMG Spoiler! Click here to view!
get list of adjacent cells. iterate: check type of item in cell, if trap, get canvas and draw X on cell.

all traps are now visible.


ZOMG Spoiler! Click here to view!
I had a similar idea, although it involved moving the teleporters. Won't work - all traps are visible - they have a different symbol. Just some teleporters teleport you onto them. Obvious if you actually follow the code through too.

If you're going to expect me to look at what's on the screen before I fumble up a solution to it, we're going to have some serious problems.

Edit - Woo, I'm a winner!

Author:  Pod [ Sat Apr 19, 2014 13:25 ]
Post subject:  Re: JavaScript game

Is there any way to start from a certain level? When I unrecoverably deleted all my code with a single keystroke on level 14 or whatever I ragequit. But not I want to continue on, and I don't feel like doing 1-14 again.

Author:  Mr Dave [ Sat Apr 19, 2014 13:53 ]
Post subject:  Re: JavaScript game

Pod wrote:
Is there any way to start from a certain level? When I unrecoverably deleted all my code with a single keystroke on level 14 or whatever I ragequit. But not I want to continue on, and I don't feel like doing 1-14 again.

Gwt the computer on the firt level, then go to the menu in the bottom right

I ws forever hitting Ctrl W to get rid of the API help...
I'd provide code for you, but I doubt you mean 1-14

Author:  Pod [ Sat Apr 19, 2014 15:34 ]
Post subject:  Re: JavaScript game

Mr Dave wrote:
Pod wrote:
Is there any way to start from a certain level? When I unrecoverably deleted all my code with a single keystroke on level 14 or whatever I ragequit. But not I want to continue on, and I don't feel like doing 1-14 again.

Gwt the computer on the firt level, then go to the menu in the bottom right

I ws forever hitting Ctrl W to get rid of the API help...
I'd provide code for you, but I doubt you mean 1-14


Aha! Just what I wanted, although I was playing this on a different computer (at work). I got to the robot maze and was in the middle of doing that -- I think it was level 13 or 14 or something? When I re-do it I'll use MrD's cheaty method, as that's similar to what I was trying to do before but couldn't do the javascript gymnastics. (For the maze I was originally working on a proper path finding thing before I DELETED IT ALL :'()

Author:  MrD [ Mon Apr 21, 2014 4:05 ]
Post subject:  Re: JavaScript game

It would be good if you could easily skip levels without a save game. I find myself on different computers a lot and would like to have another crack at the complicated robot maze ones.

ZOMG Spoiler! Click here to view!
I had a lame idea for a solution which would assign every cell a value based on its distance from the exit, and the robot would pick a random direction from the list of available cells with the lowest value, if the robot was surrounded by cells that were higher in value than the cell it currently occupied, it would set the value of the cell it currently occupied to a high value first before leaping off it to make sure it never visited it again. Crappy pathfinding, but I wanted to see if it made sense.

Author:  Pod [ Mon Apr 21, 2014 18:34 ]
Post subject:  Re: JavaScript game

MrD wrote:
It would be good if you could easily skip levels without a save game. I find myself on different computers a lot and would like to have another crack at the complicated robot maze ones.

ZOMG Spoiler! Click here to view!
I had a lame idea for a solution which would assign every cell a value based on its distance from the exit, and the robot would pick a random direction from the list of available cells with the lowest value, if the robot was surrounded by cells that were higher in value than the cell it currently occupied, it would set the value of the cell it currently occupied to a high value first before leaping off it to make sure it never visited it again. Crappy pathfinding, but I wanted to see if it made sense.



http://www.policyalmanac.org/games/aStarTutorial.htm :)

Author:  MrD [ Tue Apr 22, 2014 22:37 ]
Post subject:  Re: JavaScript game

YUP. Though I knew about a star already, my implementation would have been a lousy bus-ride-home-back-of-napkin version without any of the list maintaining. (It's all the same stuff, so anything I don't write explicitly would be implicit.)

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/