Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help on Bombing Run [SOLVED]

#1

I don’t understand some of the concepts. Here is my code:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # Find the vector of attack
        vector = Vector.add(enemy.pos, hero.pos)
        # Use trigonometry to find the the angle in Radians!
        radians = Math.atan2(hero.pos, vector)
        degrees = radians * (180 / Math.PI)
        hero.say(degrees)

There are no errors, the hero doesn’t even say a number. I think this part of the code:

        # Find the vector of attack
        vector = Vector.add(enemy.pos, hero.pos)
        # Use trigonometry to find the the angle in Radians!
        radians = Math.atan2(hero.pos, vector)

is incorrect. Can someone please help? And maybe even explain what the answer means?

1 Like
#2

which area are you in for that level

1 Like
#3

I don’t know what you mean.

1 Like
#4

It’s in the glacier. (don’t want to confuse anyone :wink:.
:lion:

1 Like
#5

You have located the incorrect code.
vectors
A is the vector of your hero.
R is the vector of your enemy
B is the griffins’ attack vector

2 Likes
#6

Can you please explain the diagram? I really want to understand this.

@Deadpool198
Actually, it’s in the glacier.

1 Like
#7

Actually, I figured it out. Thanks to everyone for replying.

1 Like
#8

Ha ha, I didn’t realize.
:lion:

1 Like