Basin Stampede Problem

Mam problem z poziomem wymienionym wyżej, nie zgadzają się x i y, nie wiem już co mam zrobić.
Pomożecie?

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

Cześć Tomas i witaj na forum!

Poleciłbym zacząć od yPos jako wartości statycznej … takiej jak yPos = 17

Następnie, używając następujących instrukcji if, dodaj lub odejmij 3 w razie potrzeby … nie musisz dostosowywać komponentu x, ponieważ jest on aktualizowany za każdym razem, gdy iteruje pętla.

English

Howdy Tomas and welcome to the forum!

I would recommend starting with yPos as a static value…such as yPos = 17

Then, using the following if statements, add or subtract 3 as needed…you don’t need to adjust the x component, as that is updated each time the loop iterates.

1 Like