Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Hunter Valley-(Please Help)

Hey guys, I really need help on hunter valley I don’t know how the function works so I just did the opposite of the first function

Here’s my code:

// Escape to the right side of the valley.

// The function has the hero move to down and right.
function moveDownRight(shift) {
    hero.moveXY(hero.pos.x + shift, hero.pos.y - shift);
}

// The function has the hero move to up and right.
function moveUpRight(shift) {
    // Complete this function:
    hero.moveXY(hero.pos.x - shift, hero.pos.y + shift);
}


// The hunter is kind and will show the route.
var hunter = hero.findFriends()[0];
var route = hunter.route;
var routeIndex = 0;

while (routeIndex < route.length) {
    var direction = route[routeIndex];
    if (direction > 0) {
        moveUpRight(8);
    } 
    else  {
        // Use a function moveDownRight with the shift 8:
        moveDownRight(8);
    }
    routeIndex += 1;
}


//Help Me Please

You’re almost right.
This bit’s wrong:

Think about how an X-Y grid works:


The X goes across, and the Y goes up. It’s the same in codecombat.
So the second move command: MoveDownRight, wants to move across and down you need to minus shift of Y, you’ve done that right, and what should you do to X to make your hero go Right across the screen. Should you minus or add?
I hope this makes sense,
Danny

1 Like

Thanks again Deadpool198!

But no, I don’t understand.

Yeah I think I got it now. Thanks a lot deadpool! I finished the level with your help!

Which level is this because I don’t remember playing this one.

am i on the dead pool 198th place? Haha

hahah lol(20 characters)