极客战记-平常的一天
如果你卡在这里了,那么看看这个攻略吧
准备工作
1、选择英雄和编程语言
2、选择装备
3、写中文注释
python
1、写代码
2、运行
javascript
1、写代码// 打败食人嵌朗醚躅魔,收集金币。一切都那么平常。// 使用 与(AND) 在同一行检查存在性和类型。while (true) { var enemy = hero.findNearestEnemy(); // 有了与(AND),只在敌人存在时检查类型 if (enemy && enemy.type == "munchkin") { hero.attack(enemy); } // 寻找最近的物品 var coin = hero.findNearestItem(); // 如果有类型为 “coin” (金币)的物品存在,那就快去收集它! if(coin && coin.type=="coin") { hero.moveXY(coin.pos.x, coin.pos.y);}}
2、运行
coffeescript
1、写代码# 打败食人魔,收集金币。一切都那么平常。# 使用 与(AND) 在同一行检查存在性和类型。while true enemy = hero.findNearestEnemy() # 有了与(AND),只在敌人存在时检查类型 if enemy and enemy.type == "munchkin" hero.attack(enemy) # 寻找最近的物品 a=hero.findNearestItem() if a and a.type=="coin" hero.moveXY(a.pos.x, a.pos.y) # 如果有名为 “coin” (金币)的物品存在,那就快去收集它!
2、运行
lua
1、写代码-- 打败食人嵌朗醚躅魔,收集金币。一切都那么平常。-- 使用 与(AND) 在同一行检查存在性和类型。while true do loc锾攒揉敫al enemy = hero:findNearestEnemy() -- 有了与(AND),只在敌人存在时检查类型 if enemy and enemy.type == "munchkin" then hero:attack(enemy) end -- 寻找最近的物品 local item = hero:findNearestItem() -- 如果有类型为 “coin” (金币)的物品存在,那就快去收集它! if item and item.type == "coin" then hero:moveXY(item.pos.x, item.pos.y) endend
2、运行