{SOLVED}Hunter valley help please

@Code_Kid13

def moveDownRight(step):
    hero.moveXY(hero.pos.x +- step, hero.pos.y - step)

# The function has the hero move to up and right.
def moveUpRight(step):
    # Complete this function:
    hero.moveXY(hero.pos.x - step, hero.pos.y + step)
    pass

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

while routeIndex < len(route):
    direction = route[routeIndex]
    if direction > 0:
        moveUpRight(8)
    else:
        # Use a function moveDownRight with the shift 8:
        moveDownRight(8)
        pass
    routeIndex += 1

I have been stuck on this level for days i need help so badly i am using Alejandro the Duelist and the level is hunter valley and i cannot get to the east side! :no_entry_sign:
image
here is what i am wearing

I completed it first try. You model the moveUpRight like the moveDownRight, only you add step after hero.pos.y. Then, when it asks for the shift of 8, on moveDownRight, you do:

moveDownRight(8)

That’s it.

@dedreous

i still am stuck

@dedreous

while True:
    def moveDownRight(step):
        hero.moveXY(hero.pos.x +- step, hero.pos.y - step)
    pass
    def moveUpRight(step):
        hero.moveXY(hero.pos.x - step, hero.pos.y + step)
    pass



First thing I see…in your moveDownRight, are you adding or subtracting step?

In both of the move functions: the hero starts at 9, 35. To move right, you add to the first element (x); to move down, you subtract from the second element (y) and to move up, you add to it instead.

Because you are using routeIndex as a counter, you need to increment it…right now, it is always going to = 0.

here is my new code

# Escape to the right side of the valley.

# The function has the hero move to down and right.
def moveDownRight(step):
    hero.moveXY(hero.pos.x + step, hero.pos.y - step)

# The function has the hero move to up and right.
def moveUpRight(step):
    # Complete this function:
    hero.moveXY(hero.pos.x + step, hero.pos.y - step)
    pass

# The hunter is kind and will show the route.
hunter = hero.findFriends()[0]
route = hunter.route
routeIndex = 0
while routeIndex < len(route):
    direction = route[routeIndex]
    if direction != 0:
        moveUpRight(8)
    else:
        # Use a function moveDownRight with the shift 8:
        moveDownRight(8)
        pass
    routeIndex += 1


Ok, better…line 10, you are telling hero to move down; line 19, was correct the first time - it needs to be > 0

It is supposed to be

hero.moveXY(hero.pos.x + step, hero.pos.y + step)

on def moveUpRight

# Escape to the right side of the valley.

# The function has the hero move to down and right.
def moveDownRight(step):
    hero.moveXY(hero.pos.x + step, hero.pos.y - step)

# The function has the hero move to up and right.
def moveUpRight(step):
    # Complete this function:
    hero.moveXY(hero.pos.x + step, hero.pos.y + step)
    pass

# The hunter is kind and will show the route.
hunter = hero.findFriends()[0]
route = hunter.route
routeIndex = 0
while routeIndex < len(route):
    direction = route[routeIndex]
    if direction != 0:
        moveUpRight(8)
    else:
        moveDownRight(8)
        pass
routeIndex += 1

Your final statement is out of alignment…

1 Like

no i already solved it the is before i solved it

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.