敵人不再我的視野內?
您好,欢迎到论坛!
您能否将下面主题中描述的代码发送给我们,以便我们能够在一级帮助您并更好地查看您的代码?
Andrei
使用loop循環移動並攻擊目標
enemy = hero.findNearestEnemy()
while True:
hero.moveRight()
hero.moveUp()
hero.moveRight()
hero.attack(enemy)
hero.moveDown(2)
hero.moveUp()
pass
您能否按照以下主题中的描述正确设置代码格式?
Andrei
enemy = hero.findNearestEnemy()
while True:
hero.moveRight()
hero.moveUp()
hero.moveRight()
hero.attack(enemy)
hero.moveDown(2)
hero.moveUp()
pass
是這樣嗎?
1 Like
是。 现在尝试在此行之前留出4个空格
并在每次攻击之前找到敌人(因此在攻击代码之前将其放入循环中).
Andrei
enemy = hero.findNearestEnemy()
while True:
hero.moveRight()
hero.moveUp()
hero.moveRight()
hero.attack(enemy)
hero.moveDown(2)
hero.moveUp()
pass
他就是一直出現敵人在你的視野裡嗎? 照理來說我往又往上之後就會看到敵人 攻擊放在往上往右之後他還是顯示敵人在你的視野裡嗎?
尝试在此之前找到敌人
因为英雄并不总是可以看到敌人(除非您有暮光之眼镜)。
Andrei
我是有戴上眼鏡的!!!
你不能.
Andrei
我實在不懂你的說法
那請問我寫的code是對的嗎?
您的代码还不够好。 因此,在攻击线之前找到敌人,然后就可以了。
Andrei
我知道要在攻擊前發現敵人 但是提示並沒有說怎麼做到發現敵人?? 前面也沒有教 能請問該怎麼寫嗎?
已經解決了 謝謝!!!
没问题! 并祝贺您完成水平!
Andrei
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.