astros avatar

CodeCombat代码战记第一天

astros

Published: 10 Apr 2018 › Updated: 10 Apr 2018CodeCombat代码战记第一天

CodeCombat代码战记第一天

第一个场景是地牢,基础的15关比较简单,主要是学习下面这些知识点:

  • 四个移动函数: moveLeft moveRight moveUp moveDown
  • 攻击函数: attack(变量)
  • 循环语句: while True:
  • 变量和字符串的区分: 变量不带引号,字符串带引号
  • 找到最近敌人的函数:findNearestEnemy()
  • 建造围栏函数: buildXY("fence", x, y)

贴个第15关的代码:

hero.moveDown()
hero.buildXY("fence", 36, 34)
hero.buildXY("fence", 36, 30)
hero.buildXY("fence", 36, 26)
hero.moveRight()
hero.moveRight()
hero.moveRight()
hero.moveRight()

很简单吧!
明天继续!


Leave CodeCombat代码战记第一天 to:

Written by

在南美呆过一段时间,对科技很感兴趣,目前在学Python

Read more #cn posts


Best Posts From astros

We have not curated any of astros's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From astros