秒読み
間に合って味方の鬼との戦いを支援する為のお金を集めよう
目標
鬼を攻撃する
コインを集める
With now() you can change your actions based on how much time has passed.
Also ,chain if statements together with else-if:
今()によって、あなたは、いくらの時間が過ぎたかに基づいてあなたの行動を変更できる。
またチェーン ならば 他にならばとともにステートメント :
if(hero.now()<10{
//attack
} else if (hero.now() < 30 {
// collect coins
}
ヒント
あなたの新しい技を使ってどうするかを決めよう hero.now()
最初の10秒なら、戦おう
そうでなければ、最初の35秒なら、コインを集めよう
35秒が経ったら攻撃に加わろう!
解答
a
while(true) {if (hero.now() < 10) {
hero.attack(hero.findNearestEnemy());
} else if (hero.now() < 35) {
hero.moveXY(hero.findNearestItem().pos.x, hero.findNearestItem().pos.y);
} else {
hero.moveXY(54, 50);
hero.attack(hero.findNearestEnemy());
a
- 最終更新:2016-05-08 10:36:19