codecombat中国游戏网址:http://www.codecombat.cn/

全部代码为javascript代码分享



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



1、Boom! and Bust



// Use your buildXY hammer to build two "fire-trap"s near the gate.

// They will detonate when you move back to a safe distance!

// Then, make a run for the forest!

this.buildXY("fire-trap", 35, 35);

this.buildXY("fire-trap", 35, 30);

this.moveLeft(1);

this.moveRight(3);



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



2、森林保卫战



// 建立两个围栏保护村民

// 把鼠标放在地图上得到X,Y坐标

this.buildXY("fence", 40, 52);

this.buildXY("fence", 40, 20);



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



3、羊肠小道



// 到小路的尽头去,并在那儿修一个栅栏。

// 利用你的 moveXY(x, y)坐标移动功能。

this.moveXY(34, 45);

this.moveXY(36, 59);

this.moveXY(36, 42);

this.moveXY(48, 22);

this.moveXY(36, 13);

this.moveXY(71, 17);

this.moveXY(73, 63);

this.moveXY(71, 17);



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



4、咬手指的人



// 仅仅有当 if 条件为真的时候,if 语句以下的命令才会运行。

// 在条件中。==表示左右两边相等

if (2 + 2 == 4) {

    this.say("Hey!");

}

if (2 + 2 == 5) {

    this.say("Yes, you!");

}



// 改变这里的条件让你的英雄说『来找我!』

if (1) {  // ? Make this true.

    this.say("Come at me!");

}



if (1) {  // ? Make this true.

    // 加入一句或者很多其它骂人的话来吸引食人魔,来点有创意的!

    this.say("fuck you bitch !");

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



5、宝石或者死亡



// 在 if 条件下的命令仅仅有在条件为真的时候执行。

// 修复全部的 if 条件判定来赢得本关



// ==的意思是等于

if (1 + 1 + 1 == 4) {  // ?

Make this false.

    this.moveXY(5, 15);  // 移动到第一个地雷位置

}

if (2 + 2 == 4) {  // ? Make this true.

this.moveXY(15, 41);  // 移动到第一个宝石的位置。

}

// !=的意思是不等于

if (2 + 2 != 3) {  // ?

Make this true.

this.moveXY(25, 16);  // 移动到第二个宝石的位置

}

// <的意思是比什么小

if (2 + 2 < 5) {  // ?

Make this true.

    var enemy = this.findNearestEnemy();

    this.attack(enemy);

}

if (2 < 1) {  // ? Make this false.

this.moveXY(40, 55);

}

if (false) {  // ? Make this false.

this.moveXY(50, 10);

}

if (true) {  // ? Make this true.

this.moveXY(55, 26);

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



6、边远伏击



// 移动到各个节点。并消灭每个食人魔。

this.moveXY(24, 42);

var enemy1 = this.findNearestEnemy();

// 在攻击之前。使用if语句来确保当前有敌人存在。

if (enemy1) {

this.attack(enemy1);

this.attack(enemy1);

}



this.moveXY(27, 60);

var enemy2 = this.findNearestEnemy();

if (enemy2) {

this.attack(enemy2);

this.attack(enemy2);

}



this.moveXY(42, 50);

// 再使用一个if语句并攻击!

var enemy3 = this.findNearestEnemy();

if(enemy3){

    this.attack(enemy3);

    this.attack(enemy3);

}



// 移动到下一个节点并消灭剩余的食人魔。

this.moveXY(39, 24);

var enemy4 = this.findNearestEnemy();

if(enemy4){

    this.attack(enemy4);

    this.attack(enemy4);

}



this.moveXY(55, 29);

var enemy5 = this.findNearestEnemy();

if(enemy5){

    this.attack(enemy5);

    this.attack(enemy5);

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



7、巡逻兵克星





//记得提升自己的装备水平

// 记得敌人可能还不存在。

loop {

    enemy = this.findNearestEnemy();

    // 假设是敌人。攻击它!

if(enemy){

        this.attack(enemy);

    }

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



8、濒危树林之战



// 仅仅攻击幼小食人魔和投掷者食人魔。

// 别攻击树榴,遇到食人魔快跑。

loop {

    var enemy = this.findNearestEnemy();



    // 记住:别攻击树榴『burl』

    if (enemy.type == "burl") {

        this.say("我不攻击树榴『burl』");

    }

    

    // type 属性告诉你它是什么种类的生物

    if (enemy.type == "munchkin") {

        this.attack(enemy);

    }

    

    // 使用『if』来攻击投掷者『thrower』

    if (enemy.type == "thrower") {

        this.attack(enemy);

    }

    // 假设它是一个食人魔『ogre』,跑到村口去!

if (enemy.type == "ogre") {

        this.moveXY(20, 40);   

    }

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



9、村庄守护者



// 在村口巡逻。

// 假设发现敌人,击杀他们。

loop {

    this.moveXY(35, 34);

    var leftEnemy = this.findNearestEnemy();

    if (leftEnemy) {

        this.attack(leftEnemy);

        this.attack(leftEnemy);

    }

    // 如今移动到右側。

    this.moveXY(60, 34);

    // 使用if指令推断是否有敌人。有的话,击杀他们。

    var rightEnemy = this.findNearestEnemy();

    if (rightEnemy) {

        this.attack(rightEnemy);

        this.attack(rightEnemy);

    }  

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



10、荆棘农场



// 在村口巡逻。

// 当你见到食人魔。建立一个火焰陷阱。

// 不要让不论什么农民受到伤害。



loop {

    this.moveXY(43, 50);

    var topEnemy = this.findNearestEnemy();

    if (topEnemy) {

        this.buildXY("fire-trap", 43, 50);

    }



    this.moveXY(25, 34);

    var leftEnemy = this.findNearestEnemy();

    if (leftEnemy) {

        this.buildXY("fire-trap", 25, 34);

    }

    

    this.moveXY(43, 20);

    var buttomEnemy = this.findNearestEnemy();

    if (buttomEnemy) {

        this.buildXY("fire-trap", 43, 20);

    }

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



11、背靠背



// 呆在中间防守



loop {

    var enemy = this.findNearestEnemy();

    if (enemy) {

        // 主动出击

        this.attack(enemy);

    }

    else {

        // 回到你的阵地防守

        this.moveXY(40, 34);

    }

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



番外:地牢第38关~~毁灭天使



this.moveDown();

// 妈妈总对我说,随便吃点你在地牢里找到的蘑菇。

this.moveRight();

this.moveDown();

this.moveUp();

this.moveLeft();

this.moveDown(2);

this.moveRight(4);

this.moveUp();

this.moveLeft();

this.moveUp();

this.moveRight();

this.moveUp();

this.moveLeft();

this.moveDown();

// 找到你去地牢守卫者的路。

loop {

    var enemy = this.findNearestEnemy();

    if (enemy) {

        this.attack(enemy);

    }

}

最新文章

  1. [翻译]通过使用正确的search arguments来提高SQL Server数据库的性能
  2. 利用mybatis的分页插件实现商品列表的显示
  3. CCAction
  4. Html - 仿Ios assistiveTouch 悬浮辅助球工具
  5. IE7浏览器下CSS属性选择器二三事
  6. python 安装操作 MySQL 数据库.
  7. 最大子段和问题,最大子矩阵和问题,最大m子段和问题
  8. 函数还能这样玩儿~实现类似add(1)(2)(3)的函数
  9. asp.net数据库操作类(二)
  10. Android Bug 记录
  11. HDU 1198 Farm Irrigation (并检查集合 和 dfs两种实现)
  12. flex日期合并与拆分
  13. CQRS微服务架构模式
  14. idea构建spark开发环境,并本地运行wordcount
  15. 关于怎样获取DevExpress GridView过滤后或排序后的数据集问题(转)
  16. mysql实现自增函数
  17. 滚动条事件window.onscroll
  18. iOS开发-类簇(Class Cluster)
  19. list列表常用方法
  20. linux有用技巧:使用ntfs-3g挂载ntfs设备

热门文章

  1. k8s istio 配置请求的路由规则
  2. 实体类中方法名尽量避免set,get,报错com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException)
  3. [XJOI]noip40 T2统计方案
  4. C# 添加应用程序包
  5. MVC中使用UpdateModel获取接口参数
  6. 第6章 服务模式 Service Interface(服务接口)
  7. YCbCr to RGB and RGB toYCbCr
  8. Three学习之曲线
  9. 【Oracle】创建概要文件
  10. 继承&amp;封装