【转载】网易极客战记官方攻略-游戏开发1-投火

关卡连接:https://codecombat.163.com/play/level/throwing-fire

免费试玩:https://codecombat.163.com/play

Okar 有些游戏对象可以设置属性。

简介

有些游戏对象可以设置属性。

"fire-spewer" 能喷射火球!

默认喷射方向是 "horizontal" (横向)。

你可以将属性改为 "vertical" ,让其纵向喷射,代码如下:

spew = game.spawnXY("fire-spewer", 40, 40) spew.direction = "vertical"

默认代码

# 游戏对象可以设置属性。

 # 不要改变这个,它是设置游戏的。

player = game.spawnPlayerXY("knight", 40, 10) game.addCollectGoal() game.addSurviveGoal()

game.spawnXY("gem", 32, 55)

game.spawnXY("gem", 51, 55)

  fs1 = game.spawnXY("fire-spewer", 12, 25) fs2 = game.spawnXY("fire-spewer", 70, 30) fs3 = game.spawnXY("fire-spewer", 12, 35) fs4 = game.spawnXY("fire-spewer", 70, 40)

# 将fs1.direction改成"vertical":

fs1.direction = "horizontal" # ∆ Change this.

 # 再将fs2.direction改成"vertical":

 # fs3和fs4也这样做:

 # 下面开始游戏并收集宝石!

概览

Coming soon!

投火 解法

# 游戏对象可以设置属性。 # 不要改变这个,它是设置游戏的。 player = game.spawnPlayerXY("knight", 40, 10) game.addCollectGoal() game.addSurviveGoal() game.spawnXY("gem", 32, 55) game.spawnXY("gem", 51, 55) fs1 = game.spawnXY("fire-spewer", 12, 25) fs2 = game.spawnXY("fire-spewer", 70, 30) fs3 = game.spawnXY("fire-spewer", 12, 35) fs4 = game.spawnXY("fire-spewer", 70, 40) # 将fs1.direction改成"vertical": fs1.direction = "vertical" # 再将fs2.direction改成"vertical": fs2.direction = "vertical" # fs3和fs4也这样做: fs3.direction = "vertical" fs4.direction = "vertical" # 下面开始游戏并收集宝石!  

本攻略发于极客战记官方教学栏目,原文地址为:

https://codecombat.163.com/news/jikezhanji-touhuo

极客战记——学编程,用玩的!  
上一篇:【MATLAB编程实例练习】-(8)迷路的牛牛


下一篇:flex全屏布局