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.

1 Like
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)
1 Like

Thanks. Iā€™ll look at it now.

1 Like

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

Andrei

2 Likes

You wrote:

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

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

2 Likes

Donā€™t forget to redefine the variable when you do that.

2 Likes
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

2 Likes
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.

1 Like

@Rachel699 You mean yPos because that is the variable for the heroā€™s y position

2 Likes

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

2 Likes

Oopsā€¦ I wasnā€™t copy pastingā€¦ thanks for the reminder! :sweat_smile:

2 Likes

No problem! :grinning:

2 Likes

Does this work for you? :slightly_smiling_face:

2 Likes
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.

1 Like

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

1 Like