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
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
I checked my gear and I don’t think it is the problem
Ok, as said i Can only make assumptions right now…
Maybe, you have too much space between „ y = y +3“ or by „y = y -3“?
Hey @avery_witte,
Welcome to CodeCombat Discourse! 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.
That should be good…
maybe I could check the code
Irregular whitespaces should be fine for Python. It’s the variable naming that’s making the code break.
oh thanks that fixed the problem
SO, did you complete the level?
yes I did I did complete the level
Then, congrats!
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?