Be Excellent To Each Other

And, you know, party on. Dude.

All times are UTC [ DST ]




Reply to topic  [ 28 posts ] 
Author Message
 Post subject: JavaScript game
PostPosted: Sun Apr 13, 2014 18:00 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
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.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 19:50 
User avatar

Joined: 30th Mar, 2008
Posts: 14145
Location: Shropshire, UK
That really is really fucking good, isn't it?


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 20:06 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
Yeah, clever bastards. Did you get to the end?

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 20:25 
User avatar

Joined: 30th Mar, 2008
Posts: 14145
Location: Shropshire, UK
Nah, got a bit bored at the start of chapter 2, but I expect I'll go back to it.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 22:57 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
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!

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 23:12 
User avatar
Isn't that lovely?

Joined: 30th Mar, 2008
Posts: 10932
Location: Devon
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

_________________
Where's the Kaboom? I was expecting an Earth shattering Kaboom!


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sun Apr 13, 2014 23:18 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
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.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 15, 2014 0:09 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 15, 2014 2:09 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
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.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 15, 2014 2:27 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 15, 2014 9:52 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
Yeah, the error handling makes life complicated.

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

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 15, 2014 10:04 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Wed Apr 16, 2014 9:09 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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?

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Wed Apr 16, 2014 9:14 
User avatar

Joined: 30th Mar, 2008
Posts: 14145
Location: Shropshire, UK
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...


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Wed Apr 16, 2014 9:17 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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.

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Wed Apr 16, 2014 9:23 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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.

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Wed Apr 16, 2014 10:28 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
FUCK OFF

I pressed ctrl+4 instead of ctrl + 5.

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Fri Apr 18, 2014 5:28 
User avatar
What-ho, chaps!

Joined: 30th Mar, 2008
Posts: 2139
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.

_________________
[www.mrdictionary.net]


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Fri Apr 18, 2014 9:08 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Fri Apr 18, 2014 12:57 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69507
Location: Your Mum
I actually lucked through that one when trying something else :)

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Fri Apr 18, 2014 13:07 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sat Apr 19, 2014 3:47 
User avatar
What-ho, chaps!

Joined: 30th Mar, 2008
Posts: 2139
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!

_________________
[www.mrdictionary.net]


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sat Apr 19, 2014 13:25 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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.

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sat Apr 19, 2014 13:53 
User avatar
Paws for thought

Joined: 27th Mar, 2008
Posts: 17154
Location: Just Outside That London, England, Europe
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


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Sat Apr 19, 2014 15:34 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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 :'()

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Mon Apr 21, 2014 4:05 
User avatar
What-ho, chaps!

Joined: 30th Mar, 2008
Posts: 2139
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.

_________________
[www.mrdictionary.net]


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Mon Apr 21, 2014 18:34 
User avatar
MR EXCELLENT FACE

Joined: 30th Mar, 2008
Posts: 2568
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 :)

_________________
This man is bound by law to clear the snow away


Top
 Profile  
 
 Post subject: Re: JavaScript game
PostPosted: Tue Apr 22, 2014 22:37 
User avatar
What-ho, chaps!

Joined: 30th Mar, 2008
Posts: 2139
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.)

_________________
[www.mrdictionary.net]


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 28 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Majestic-12 [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search within this thread:
cron
You are using the 'Ted' forum. Bill doesn't really exist any more. Bogus!
Want to help out with the hosting / advertising costs? That's very nice of you.
Are you on a mobile phone? Try http://beex.co.uk/m/
RIP, Owen. RIP, MrC.

Powered by a very Grim... version of phpBB © 2000, 2002, 2005, 2007 phpBB Group.