Basin Stampede Help

? You need to format your code correctly for us to be able to look at your code. So again, please use </> and paste your code.

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.
            hero.pos.y = #subtract 3 from the hero.pos.y
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            hero.pos.y = #add 3 to hero.pos.y
            pass
    hero.moveXY(xPos, yPos)

Thanks. I’ll look at it now.

Try to look at this lines, does it seems anything wierd with them?

Andrei

You wrote:

hero.pos.y = #subtract 3 from the hero.pos.y

instead of that, you should type hero.pos.y - 3

Don’t forget to redefine the variable when you do that.

i did it next:`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.
            hero.pos.y - 3
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            hero.pos.y = #add 3 to hero.pos.y
            pass
    hero.moveXY(xPos, yPos)
`

Also, you wrote

hero.pos.y = #add 3 to hero.pos.y

Instead of #add 3 to hero.pos.y , add 3 to hero.pos.y by hero.pos.y = hero.pos.y + 3

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.
            hero.pos.y - 3
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            hero.pos.y + 3
            pass
    hero.moveXY(xPos, yPos)

Does that work for you?

nope not at all i keep dieing

As I said earlier, instead of hero.pos.y - 3 replace it with hero.pos.y = hero.pos.y - 3.

@Rachel699 You mean yPos because that is the variable for the hero’s y position

Also, instead of hero.pos.y + 3 replace it with yPos = hero.pos.y + 3

Oops… I wasn’t copy pasting… thanks for the reminder! :sweat_smile:

No problem! :grinning:

Does this work for you? :slightly_smiling_face:

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.
            ypos = hero.pos.y - 3
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            ypos = hero.pos.y + 3
            pass
    hero.moveXY(xPos, yPos)
```nope

Instead of ypos , make sure to capitalize it so it’s yPos . This should work.

And if it does, please don’t post solutions. We want other users to learn, not copy and paste off the forum.