Bombing Run, my hero can't say the angle


#1

Incoming oscars! (That’s military speak for ogres).

You will need to calculate their angle of attack.

Use that angle to command your Griffin Bombers!

while True:
enemy = hero.findNearestEnemy()
if enemy:
# Find the vector of attack
G=Vector(enemy.pos.x,enemy.pos.y)
# Use trigonometry to find the the angle in Radians!
A=Vector.subtract(hero.pos, enemy.pos)
if enemy.pos.x>hero.pos.x:
B=enemy.pos.x-hero.pos.x
else:
B=hero.pos.x-enemy.pos.x
degree=B/A
# The answer must be in Degrees!
# To convert Radians to Degrees multiply by (180 / Math.PI)
degree=degree*180/Math.PI
# Say the angle!
hero.say(degree)