极客战记-春雷

2025-11-19 13:12:49

1、选择英雄和编程语言

极客战记-春雷

2、选择装备

极客战记-春雷

3、写中文注释

极客战记-春雷

1、写代码

# Certain coins and gems attract lightning.

# 这个英雄应只收集银币和蓝宝石

while True:

    item = hero.findNearestItem()

    # A silver coin has a value of 2.

    # Collect if item.type is equal to "coin"

    # AND item.value 相等于2

    if item.type == "coin" and item.value == 2:

        hero.moveXY(item.pos.x, item.pos.y)

    # 一个蓝宝石价值10

    # Collect if item.type is equal to "gem"

    # AND item.value is equal to 10.

    if item.type == "gem" and item.value == 10:

        hero.moveXY(item.pos.x, item.pos.y)

极客战记-春雷

2、运行

极客战记-春雷

1、写代码

// 某些硬币和宝石吸引闪电。

// 这个英雄应只收集银币和蓝宝石

while (true) {

    var item = hero.findNearestItem();

    // 一枚银币的价值为2。

    // 如果item.type等于“coin”,则收集

    // AND item.value 相等于2

    if (item.type == "coin" && item.value == 2) {

        hero.moveXY(item.pos.x, item.pos.y);

    }

    // 一个蓝宝石价值10

    // 如果item.type等于“gem”,则收集

    // AND item.value等于10。

    if (item.type == "gem" && item.value == 10) {

        hero.moveXY(item.pos.x, item.pos.y);

    }}

极客战记-春雷

2、运行

极客战记-春雷

1、写代码

# Certain coins and gems attract lightning.

# 这个英雄应只收集银币和蓝宝石

while true        

    item = hero.findNearestItem()

    # A silver coin has a value of 2.

    # Collect if item.type is equal to "coin"

    # AND item.value 相等于2

    if item.type == "coin" and item.value == 2

        hero.moveXY(item.pos.x, item.pos.y)

    # 一个蓝宝石价值10

    # Collect if item.type is equal to "gem"

    # AND item.value is equal to 10.

    if item.type == "gem" and item.value == 10

        hero.moveXY(item.pos.x, item.pos.y)

极客战记-春雷

2、运行

极客战记-春雷

1、写代码

-- 某些硬币和宝石吸引闪电。

-- 这个英雄应只收集银币和蓝宝石

while true do

    local item = hero:findNearestItem()

    -- 一枚银币的价值为2。

    -- 如果item.type等于“coin”,则收集

    -- AND item.value 相等于2

    if (item.type == "coin" and item.value == 2)  then

        hero:moveXY(item.pos.x, item.pos.y)

    end

    -- 一个蓝宝石价值10

    -- 如果item.type等于“gem”,则收集

    -- AND item.value等于10。

    if (item.type == "gem" and item.value == 10)  then

        hero:moveXY(item.pos.x, item.pos.y)

    end

end

极客战记-春雷

2、运行

极客战记-春雷

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
相关推荐
  • 阅读量:87
  • 阅读量:186
  • 阅读量:88
  • 阅读量:122
  • 阅读量:164
  • 猜你喜欢