[SOLVED] I can not seem to figure it out because I put what the game said to put but the basin just keep kicking my charecter


while True:
    enemy = hero.findNearestEnemy()
    xPos = hero.pos.x + 5
    yPos = 17
    if enemy:
        # Adjust y up or down to get away from yaks.
        if enemy.pos.y > hero.pos.y:
            # If the Yak is above you, subtract 3 from yPos.
            if enemy.pos.y < hero.pos.y:
                y = y  -3
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            y = y  +3
            pass
    hero.moveXY(xPos, yPos)

Welcome to the forum!!!
Please send me a link to the level, so that I can help u :smile:

1 Like

https://codecombat.com/play/level/basin-stampede?

Sorry, im in school on my iPad right now, and my game glitched. @AnSeDra, could you help?
Also, do you think your equipment might be a problem?
Mumbo_6

2 Likes

I checked my gear and I don’t think it is the problem

Ok, as said i Can only make assumptions right now…

1 Like

Maybe, you have too much space between „ y = y +3“ or by „y = y -3“?

1 Like

Hey @avery_witte,
Welcome to CodeCombat Discourse! :tada: Instead of y = y - 3 or y = y + 3, you must use the variable yPos or else it won’t work. If you look closely at moveXY(), it uses yPos instead of y. You can also simplify yPos = yPos - 3 or yPos = yPos + 3 to yPos -= 3 and yPos += 3. Also be sure to get in the habit of consistent whitespace. Some programming languages such as Swift will return an error if your whitespaces aren’t equal.

2 Likes

That should be good…

2 Likes

maybe I could check the code

Irregular whitespaces should be fine for Python. It’s the variable naming that’s making the code break.

1 Like

Also take in @Chaboi_3000 advice. He/she is better than me in coding :smile:

1 Like

oh thanks that fixed the problem

SO, did you complete the level?

1 Like

yes I did I did complete the level

Then, congrats! :partying_face:

1 Like

it said success but then a basin just started kicking me around at like last second while trying to get to the oasis

Can you senden a screenshot of your results?

1 Like

but it changed the success into a incomplete