# [SOLVED]In the level The mighty yak i start of with"ran out of time"

i just did the level The mighty yak and when I start it says “ran out of time”
and when I did that I doged 8 yaks and they want 4

1 Like

Were is this level and post your code plz.

1 Like

it is in the dessert and this is my code

``````# Let yaks get close, then move 10m right to dodge.
# Dodge 4 yaks to complete the level.

while True:
# Get hero's current x and y position.
x = hero.pos.x
y = hero.pos.y

# Find the nearest yak.
yak = hero.findNearestEnemy()

# If the distanceTo the yak is less than 10:
if hero.distanceTo(yak) < 10:
# To move right, add 10 to hero's x position.
hero.moveXY(25, 30)
hero.moveXY(35, 30)
hero.moveXY(52, 30)
# Use moveXY(x, y) to move!
hero.moveXY(35, 30)
hero.moveXY(25, 30)
hero.moveXY(15, 30)
hero.moveXY(43, 30)
hero.moveXY(58, 30)
pass
``````

You didn’t do what the level said, read this.

1 Like

i tryed that here let me do it again

1 Like

i am still runing out of time

1 Like

this is my new code

``````# Let yaks get close, then move 10m right to dodge.
# Dodge 4 yaks to complete the level.

while True:
# Get hero's current x and y position.
x = hero.pos.x
y = hero.pos.y

# Find the nearest yak.
yak = hero.findNearestEnemy()

# If the distanceTo the yak is less than 10:
if hero.distanceTo(yak) < 10:
# To move right, add 10 to hero's x position.
hero.moveXY(25, 30)
hero.moveXY(35, 30)
hero.moveXY(45, 30)
hero.moveXY(55, 30)
# Use moveXY(x, y) to move!

pass

``````
1 Like

You still didn’t do what it said do something like this

``````x = x + 10
``````
1 Like

yeah do this instead of all the moves

`````` x=x+10
// Use moveXY(x, y) to move!
hero.moveXY(x, y)
``````

yeah just do after what I said then you are golden.

``````hero.moveXY(x, y)
``````
1 Like

`````` if hero.distanceTo(yak) < 10:
# To move right, add 10 to hero's x position.
hero.moveXY(25, 30)
hero.moveXY(35, 30)
hero.moveXY(45, 30)
hero.moveXY(55, 30)
# Use moveXY(x, y) to move!

pass
``````

do this

``````x=x+10
hero.moveXY(x, y)
``````

or this to be a little more actuate

``````        x = x + 10
# Use moveXY(x, y) to move!
hero.moveXY(x, y)
``````
1 Like

thats not how you are supposed to do it
you have to use moveXY(x,y)

thanks that worked your a life saver

congratulations on passing

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