Now lets look at the Vector library
Taking a look at the code that ya’ll wrote lets look at what the different code does:
- What does the following code tell us?
x = Vector.x
hero.say(x + " ")
.2. What is the output from this ?
enemy = hero.findNearestEnemy()
hero.say( "Enemy x=" + enemy.pos.x + " Enemy y=" + enemy.pos.y )
hero.say( "Hero x=" + hero.pos.x + " Hero y=" + hero.pos.y )
hero.say( "vector x=" + vector.x + " Hero y=" + vector.y )
On test simulation I saw a similar output:
Enemy x=10, y=86
Hero x=52, y=15
Vector x=62, y=101
What can we conclude from this output that
Vector.add( <vector1>, <vector2> ) is doing?
And if we draw a line from our hero to the resulting point that was created (
vector) from the above code where x=62, y=101, is that there we want our Griffin riders to attack?
That point location is somewhere off the screen to the right of the Hero isn’t it?