码迷,mamicode.com
首页 > 其他好文 > 详细

「网易官方」极客战记(codecombat)攻略-沙漠-猎人谷-hunter-valley

时间:2020-06-16 18:23:42      阅读:62      评论:0      收藏:0      [点我收藏+]

标签:target   代码   需要   enter   targe   编程   时间   codec   alt   

 

技术图片
(点击图片进入关卡)

这是一个狩猎的好地方,但不是当你是诱饵的时候。

简介

技术图片

你在错误的时间出现在错误的地方。 你需要在牦牛出现之前逃跑。

利用从猎人和相对位置函数推出的路线离开这里。

默认代码

# 逃到山谷的右边

 

# 该函数能使英雄向下向右移动。
def moveDownRight(step):
    hero.moveXY(hero.pos.x + step, hero.pos.y - step)

 

# 该函数能使英雄向上和向右移动。
def moveUpRight(step):
    # 完成这个函数:

 

    pass

 

# 猎人很善良,并会展示路线。
hunter = hero.findFriends()[0]
route = hunter.route
routeIndex = 0

 

while routeIndex < len(route):
    direction = route[routeIndex]
    if direction > 0:
        moveUpRight(8)
    else:
        # 使用带Shift 8的函数moveDownRight:

 

        pass
    routeIndex += 1

概览

你还记得《地牢》中的 moveLeft 这样的古老方法吗?在这个关卡,您将创建属于自己的灵活和完善的函数。

使用‘moveDownRight‘ 的示例代码来完成 moveUpRight 函数。

猎人谷 解法

# 逃到山谷的右边

 

# 该函数能使英雄向下向右移动。
def moveDownRight(step):
    hero.moveXY(hero.pos.x + step, hero.pos.y - step)

 

# 该函数能使英雄向上和向右移动。
def moveUpRight(step):
    # 完成这个函数:
    hero.moveXY(hero.pos.x + step, hero.pos.y + step)
    pass

 

# 猎人很善良,并会展示路线。
hunter = hero.findFriends()[0]
route = hunter.route
routeIndex = 0

 

while routeIndex < len(route):
    direction = route[routeIndex]
    if direction > 0:
        moveUpRight(8)
    else:
        # 使用带Shift 8的函数moveDownRight:
        moveDownRight(8)
        pass
    routeIndex += 1
 
本攻略发于极客战记官方教学栏目,原文地址为:
 

「网易官方」极客战记(codecombat)攻略-沙漠-猎人谷-hunter-valley

标签:target   代码   需要   enter   targe   编程   时间   codec   alt   

原文地址:https://www.cnblogs.com/codecombat/p/13139569.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!