zoukankan      html  css  js  c++  java
  • 「网易官方」极客战记(codecombat)攻略-沙漠-猎人谷-hunter-valley

     

    (点击图片进入关卡)

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

    简介

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

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

    默认代码

    # 逃到山谷的右边

     

    # 该函数能使英雄向下向右移动。
    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
     
    本攻略发于极客战记官方教学栏目,原文地址为:
     
  • 相关阅读:
    this指针详解
    C++处理异常
    C++中的this指针
    c++中的string类
    c面试题总结
    c++中的引用详解
    c++中的new和delete
    函数重载
    BST(二叉排序树)的插入与删除
    ccf行车路线
  • 原文地址:https://www.cnblogs.com/codecombat/p/13139569.html
Copyright © 2011-2022 走看看