# Treasured in Ice Javascript Help CS6

I understand that this level is similar to the previous one (“Fragile Maze”). But even here, I don’t know where to start. We’re supposed to navigate through the maze and save the coordinates of places we’ve been to. But how are we then supposed to pick up the treasure? The source code is below: @dedreous @AnSeDra

``````// Find the treasure inside the maze.
// When you get the treasure, move to the exit.
// The exit is marked by the red cross. The level ends when you step on the mark.
// Some doors are blocked, some open when you are near them.

var exitPosition = {x: 150, y: 120};
var distanceBetweenRooms = 16;
var zeroShift = {x: 10, y: 10};

``````
2 Likes

Try to make a similar algorithm as in the level Fragile Maze, but store every position that you walk on in an array and after you collect the treasure, then use that array backwards to move back to the starting position. This is how I have done it.

Andrei

1 Like

Okay. I’m gonna give it a go

1 Like

This is my code from the previous level added to the source code. It’s still unclear how I’m supposed to make it to the treasure without knowing its position especially because my hero does like a lap of honour around the outside alleys of the maze. Thanks for your help.

``````// Find the treasure inside the maze.
// When you get the treasure, move to the exit.
// The exit is marked by the red cross. The level ends when you step on the mark.
// Some doors are blocked, some open when you are near them.

var theX = {x: 150, y: 120};
var distance = 16;
var zeroShift = {x: 10, y: 10};

var move = Vector(distance, 0);

while (true) {
while (!hero.isPathClear(hero.pos, direction)) {
move = Vector.rotate(move, Math.PI / 2);
}
hero.moveXY(direction.x, direction.y);
move = Vector.rotate(move, -Math.PI / 2);
}

``````

If you equip Twilight glasses then the hero can see where the treasure is?

Yes, but he can not equip them because he is not an individual.

Andrei

Sorry, but I have done the level with twilight glasses, so I do not know exactly how you find out if you got the treasure or not (try to check after every step if there is an item and after you find it, just collect it and then try to find your way to the exit).

Andrei

In the courses you cannot equip so I’m not sure what to do. I can screenshot and send to show you what the map looks like

Here is my screenshot. @AnSeDra

And also, does anyone understand what I’m supposed to do with the zeroshift variable? @dedreous @Deadpool198

Try to change the order, at one point you should have gone up, not left.

Andrei

The other doors are blocked so that’s not an option. I’m doing some research on vectors in js in general. I’ll get back to you when I find something…

2 Likes

Ok then, but I not be able to help you for much more because I will have to go to bed, I will let @dedreous and @Anna to take care of you while I am gone, all right?

1 Like

The other doors are blocked so that’s not an option. I’m doing some research on vectors in js in general. I’ll get back to you when I find something…

Ok thank you so much again Ansedra