Как обозначить местопоположение врага на этом уровне?
Привет @Anonym,
Чтобы найти позицию противника, вы можете использовать этот код:
# Чтобы найти их реальную позицию, вы используете:
enemy.pos
# Чтобы найти их "X" pos вы используете:
enemy.pos.x
# И наконец, чтобы найти их "Y", вы можете использовать:
enemy.pos.y
Надеюсь, это поможет.
Hi @Anonym,
To find the position of an enemy you can use this code:
# To find their actual position you use:
enemy.pos
# To find their "X" pos you use:
enemy.pos.x
# And finally to find their "Y" pos you can use:
enemy.pos.y
I hope this helps.
Как сказать есть враг слева или справа
Чтобы увидеть, находится ли враг слева или справа от вас, используйте их «.pos.x».
Если враг справа от вас, их «.pos.x» будет больше, чем ваш.
Если их слева от вас будет меньше, чем у вас.
Посмотрите на этот график, чтобы лучше понять координаты x, y:
Если у вас все еще есть проблемы, покажите более ранние уровни (некоторые из которых находятся в лесу), где вы научитесь использовать .pos.x и .pos.y.
To see whether an enemy is to your left or right, you use their “.pos.x”.
If the enemy is to your right, their “.pos.x” will be greater than yours.
If their to your left it will be smaller than yours.
Look at this graph to better understand x, y coordinates:
—>See above
If you’re still having trouble, reveiw earlier levels (some of which are in the forest) where you learn how to use .pos.x and .pos.y.
while True:
enemy = pet.findNearestEnemy()
if not enemy:
continue
# Разведчики быстры. Нужно их остановить.
if enemy.type == "scout":
distance = pet.distanceTo(enemy)
if pet.isReady("cold-blast") and distance < 5:
pet.coldBlast()
else:
# Если враг слева от питомца:
if enemy.pos.x - 30:
# Скажи "left".
hero.say("left")
# Если враг справа от питомца:
if enemy.pos.x + 30:
# Скажи "right".
hero.say("right")
pass
Правильный ли у меня код?
Нет не совсем
Вам не нужно использовать точные суммы на этом уровне (например, 30), все, что вам нужно сделать, это решить, находится ли враг слева или справа от вас.
Вообразите это:
pos.x противника 45. Ваш pos.x 55. Они слева или справа от вас?
Посмотрите на график x, y, чтобы помочь вам ответить на мой вопрос.
Спасибо
No, not quite.
You don’t need to use exact amounts in this level (for example 30) all you need to do is work out whether the enemy is to your left, or to your right.
Imagine this:
an enemy’s pos.x is 45. Your pos.x is 55. Are they to your left or to your right?
Look at the x, y graph to help you answer my question.
Thanks
Если враг слева от питомца:
какую переменную написать чтобы сказать питомцу слева враг или справа
Привет.
Как только вы определились, находится ли враг справа или слева от питомца, вы приказываете питомцу (pet.say ()) сказать: либо “left”, если враг находится слева от вашего питомца; или “right”, если враг справа от вашего питомца.
Hi.
Once you’ve worked out whether the enemy is to the pet’s right or left, you command the pet (pet.say()) to say: either “left” if the enemy is to your pet’s left; or “right” if the enemy is to your pet’s right.
while True:
enemy = pet.findNearestEnemy()
if not enemy:
continue
# Разведчики быстры. Нужно их остановить.
if enemy.type == "scout":
distance = pet.distanceTo(enemy)
if pet.isReady("cold-blast") and distance < 5:
pet.coldBlast()
else:
# Если враг слева от питомца:
if enemy.pos.x < pet.pos.x:
# Скажи "left".
hero.say("left")
# Если враг справа от питомца:
if enemy.pos.x > pet.pos.x:
# Скажи "right".
hero.say("right")
pass
Правильный ли сейчас у меня код?
Белый медвежонок ничего не делает.
Привет, ты должен сказать, что pet.say() не hero.say().
Thank you!/ Спасибо!
My pleasure.