CodeCombat-KITHGARD关卡讲解1-20

如果打开网页出现如下内容,请直接选择不翻译,关掉此弹窗即可。

image-20260407140700411

在游戏中,未完成的关卡显示为小旗帜,完成的关卡显示为五角星。

image-20260407140947856

关卡图标识

第一部分关卡图

第1关 KITHGARD地牢

开始关卡,学习语法,方法,参数,字符串,循环,变量等。

image-20260402154149056

选择第一关,KITHGARD地牢。

image-20260407185420144

开始游戏。

添加鞋子装备,每个装备上都会有一些技能,例如当前装备了鞋子,现在有moveDown,moveLeft,moveRight,moveUp四个技能了,即上下左右移动。

image-20260402154216754

查看目标,目标是避开尖刺,收集宝石。

我们只需要按照下图步骤完成即可。

image-20260402154228548

随后在代码输入框中输入相应代码,完成游戏。

image-20260402154234332

# 向宝石进发。
# 小心尖刺!
# 在下面输入你的代码,完成后点击运行。

hero.moveRight()
hero.moveDown()
hero.moveRight()

第2关 深藏的宝石

image-20260407185435007

整体思路

image-20260402160110722

# 利用你的移动命令收集所有宝石。
hero.moveRight()
hero.moveDown()
hero.moveUp(2)
hero.moveRight()

第3关 幽影守卫

image-20260407185455123

穿戴攻击装备。

image-20260402160543852

整体思路

image-20260402160722688

# 避开食人魔的视线,收集宝石。
hero.moveRight()
hero.moveUp()
hero.moveRight()
hero.moveDown()
hero.moveRight()

第4关 健忘的宝石匠

image-20260407185510097

# 夺取宝石,然后走到出口。
hero.moveRight()
hero.moveDown()
hero.moveRight(2)
hero.moveUp()
hero.moveRight()

第5关 真实姓名

image-20260407185540200

装备武器。

image-20260402162146940

# 抵御 "Brak" 和"Treg"!
# 小食人魔攻击两次才会被击败。

hero.moveRight()
hero.attack("Brak")
hero.attack("Brak")
hero.attack("Treg")
hero.attack("Treg")

第6关 不详的征兆

image-20260407185557816

# 你的目标是保护地图右边的人存活。
# 你不需要和食人巨怪打,只管逃命!你的盟友会保护你。
hero.moveRight()
hero.moveRight()
hero.moveUp()
# Use the movement commands to reach the red X!
hero.moveRight(3)
hero.moveDown()
hero.moveRight()
hero.moveDown()
hero.moveRight()

第7关 逆时针回转

image-20260407185613685

# 避开食人魔并取走宝石。
hero.moveDown(2)
hero.moveRight()
hero.moveUp()
hero.moveRight()

第8关 敌人的陷阱

image-20260407185642474

整体思路

image-20260402161812368

# 使用带参数的移动命令,移动到更远。
hero.moveRight(3)
hero.moveUp()
hero.moveRight()
hero.moveDown(3)
hero.moveRight(2)

第9关 狭路相逢

image-20260407185657103

# 避免被食人魔看到.
hero.moveRight()
hero.moveLeft()
hero.moveRight(2)

第10关 虚幻干扰

image-20260407185714047

# 走到 X 位置,使用诱饵分散守卫注意力
hero.moveRight()
hero.moveDown(2)
hero.moveUp(2)
hero.moveRight(3)

第11关 机会有利

image-20260407185730274

# 攻击食人魔并收集宝石。
hero.moveRight()
hero.attack("Krug")
hero.attack("Krug")
hero.moveRight()
hero.moveUp()
hero.attack("Grump")
hero.attack("Grump")
hero.moveLeft(2)

第12关 工作中睡着

image-20260407185744123

# 卫兵看守着门上的开关
hero.moveUp()
# 在沉睡的食人魔之间移动:
hero.moveRight(2)
# 对着食人魔攻击两次,击败他们:
hero.attack("Bas")
hero.attack("Bas")
# 然后移动到宝石的位置,逃离房间:
hero.attack("Vera")
hero.attack("Vera")
hero.moveRight()

第13关 注释中的密语

image-20260407185801784

# 使用 “say()” 函数说出密码。
# 密码是: "Achoo"
hero.say("Achoo")
hero.moveUp(2)

第14关 祸之火焰

image-20260407185817159

# 食人魔看上去又大又慢,这种慢速移动能力帮你避免了致命进攻。
hero.moveRight()
hero.moveUp()
hero.say("hahahaha")
hero.moveDown()
hero.moveRight()

第15关 焰中舞动

image-20260407185829705

整体思路

购买图书装备,可以使用while循环。

image-20260402163123954

英雄在两端循环走动即可。

image-20260402164608413

# 代码通常按编写顺序执行。
# 循环会多次重复一个代码块。
# 按Tab或4个空格,把移动指令缩进到循环内部。

while True:
    hero.moveRight()
    # 在这里给循环里加 moveLeft 命令。
    hero.moveLeft()

第16关 KITHGARD图书管理员

image-20260407185847857

# 你需要图书馆大门的开门密码!
# 密码就在 提示 中!
# 请点击代码窗口上的蓝色 “提示” 按钮。
# 如果你在关卡中遇到了困难,请点击 “提示” 按钮!

hero.moveRight()
hero.say("Hush")  # ∆
hero.moveRight()

第17关 高举之剑

image-20260407185905128

从这一关开始,会出现小怪攻击英雄,先购买几件装备防御。

image-20260402163635628

hero.attack("Rig")
hero.attack("Rig")
hero.attack("Gurt")
hero.attack("Gurt")
hero.attack("Ack")
hero.attack("Ack")

第18关 囚犯

image-20260407185920347

更换武器。

image-20260402164059044

整体思路

image-20260402164237431

# 释放囚犯,击败守卫并夺取宝石。
hero.moveRight()
# 从"Weak Door"后解救Patrick。
hero.attack("Weak Door")
# 击败名为"Two"的守卫。
# 使用带参数的移动命令,移动到更远。
hero.moveRight(3)
hero.moveDown(3)
# 获得宝石。

第19关 循环又循环

image-20260407185934604

# 在 while true 里的代码会永远重复!
while True:
    # 右走
    hero.moveRight()
    # 向上走
    hero.moveUp()
    # 左走
    hero.moveLeft()
    # 向下走
    hero.moveDown()

第20关 闹鬼的迷宫

image-20260407185949081

整体思路

image-20260402172138405

# 循环是处理重复事情的最好方法。
while True:
    # 在这里添加需要重复运行的命令。
    hero.moveRight(2)
    hero.moveUp(2)

 

文章目录