[SOLVED] Thunderhooves - Python

Every thing else on my code is alright, I know THAT for a fact.
But I don’t know how to move right. I said x = x + 10 and thought that just putting x would work, but it doesnt, and it also said “Y is not defined” when I put in move.XY(x, y). I only need help on how to move right.

Can you post your code formatted correctly so we can see what is going on?
Lydia

# Move right, to the oasis.
# Build a "fence" above or below when you see a yak.

while True:
    x = x + 10
    yak = hero.findNearestEnemy()
    if yak:
        # If yak.pos.y is greater than hero.pos.y
        if yak.pos.y > hero.pos.y:
            # buildXY a "fence" 10m below the yak.
            hero.buildXY("fence", yak.pos.y - 10)
        else: 
            # buildXY a "fence" 10m above the yak.
            hero.buildXY("fence", yak.pos.y + 10)
        pass
    else:
        # moveXY right 10m towards the oasis.
        hero.moveXY(x y)
        pass

You always need a x position to move or build something at. So add a yak.pos.x before the yak.pos.y - 10 on both.

No, the yak.pos is fine. I just need to know how I move right, because… wait a second. I’ll be right back.

Nope nevermind. I want to know how to move right. If I move right just on the while true, using actual numbers, the yaks will charge, and my character will die.

Or it just has an error.

Look at hint four just tweak it a little bit and you will move right

Delete this

Replace this:

with this:
hero.moveXY(hero.pos.x + 10, hero.pos.y)
Lydia

1 Like

Thanks lydia! (20 char)

@Lydia_Song don’t post direct answers we help them try and solve it not just give them answers

Yeah, but this isn’t a direct answer, it is not a solution.
Lydia

It is kind of a direct answer since he can just copy and paste it and move on and complete the level

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