盆地への殺到
何かがヤクを怯えさせた! 逃げろ、命が危ない!
目標
オアシスにつく。
Uh oh, a stampede!
Dynamically dodge those dastardly yaks!
There are some simple rules for surviving a yak stampede:
1 Keep moving to the right!
The sample code gives you this part:
hero.pos.x + 5
2 Subtract from y if the yaks are above the hero (enemy.pos.y>hero.pos.y)
3 Add 3 to y if the yaks are below the hero (enemy.pos.y<hero.pos.y)
あー おお 、殺到!
動的に、それらの卑劣なヤクを避けなさい!
ヤク殺到を生き抜くことにいくつかの簡単な規則がある:
1 右に動き続けなさい!
サンプルコードはあなたにこの部分を与える:
hero.pos.x +5
2 もしヤクがヒーローの上にいるならば、yから取り去りなさい(enemy.pos.y>hero.pos.y)
3 もしヤクがヒーローの下にいるならば、3をyに追加しなさい(enemy.pos.y<hero.pos.y)
ヒント
Keep moving right, but adjust up and down as you go.
正しく動き続けるけれども、あなたが行くと、上下で適合させなさい。
解答
a
while True:
enemy = hero.findNearestEnemy()
xPos = hero.pos.x + 5
yPos = 17
if enemy:
if enemy.pos.y > hero.pos.y:
yPos-=3
elif enemy.pos.y < hero.pos.y:
yPos+=3
hero.moveXY(xPos, yPos)
a
- 最終更新:2017-05-09 00:50:22