level 1
说25就可以了 我也搞不懂那个除法
我的问题是跑过去只能打死一个怪物啊 打完就喊 “但是他已经死了” 打不了另外一个怪物,你有
正确的
码码吗?
给我看看啊
2016年03月04日 04点03分
2
level 1
边远地区的森林long-range-division代码:
enemy = self.findNearestEnemy()
distanceToEnemy = self.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
self.say("distanceToEnemy divided by 30")
self.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
self.say("distanceToEnemy divided by 20")
self.say("Fire!")
# Say these things for motivation. Really. Trust us.
self.say("Woo hoo!")
self.say("Here we go!")
self.say("Charge!!")
# Now, use a while-true loop to attack the enemies.
loop:
if enemy:
self.attack(self.findNearestEnemy())
2016年04月17日 17点04分
5
level 1
# Destroy the mines!
# Use say to call out the range to the mines.
# Use division to calculate the range.
enemy = self.findNearestEnemy()
distanceToEnemy = self.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
self.say("distanceToEnemy divided by 20")
self.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
self.say("distanceToEnemy divided by 30")
self.say("Fire!")
# Say these things for motivation. Really. Trust us.
self.say("Woo hoo!")
self.say("Here we go!")
self.say("Charge!!")
# Now, use a while-true loop to attack the enemies.
loop:
enemy = self.findNearestEnemy()
if enemy:
self.attack(enemy)
两段代码做对比,在loop循环里面要重新定义enemy,研究了1个小时。得出的经验就是一定不要忘记程序是自上而下一条条的执行的,当前面的代码执行完毕后,对后面来说是不存在的了,应为不是循环,后面在循环内部再次定义enemy的值是无关的。
2016年04月17日 17点04分
6
虽说是一条一条执行的,但是一开始的enemy是一个变量,他得到的是一个返回值,变量应该是一直存在的才对。
2017年12月11日 00点12分
level 1
其实很简单啊
敌人距离除于3是第一道炸弹墙,除于1.5是第二道炸弹墙。
self.say(distanceToEnemy/3)
self.say(distanceToEnemy/1.5)
然后loop,干掉enemy.
2016年06月23日 12点06分
7
level 1
完整通关代码是这样的
# Destroy the mines!
# Use `say` to call out the range to the mines.
# Use division to calculate the range.
enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say("distanceToEnemy divided by 30")
hero.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
hero.say("distanceToEnemy divided by 60")
hero.say("Fire!")
# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")
hero.say("Charge!!")
# Now, use a while-true loop to attack the enemies.
while True:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
2018年04月05日 14点04分
8
为什么是30 不是3呢
2018年08月20日 13点08分
level 1
enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say("first Range"+distanceToEnemy/3)
hero.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
hero.say("second range"+distanceToEnemy/1.5)
hero.say("Fire!")
# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")
hero.say("Charge!!")
while True:
enemy=hero.findNearestEnemy()
hero.attack(enemy)
2018年04月07日 08点04分
9