####My story begins like so many others; with a bug in my program.
While trying to iterate though the axles for the position of a coin, I accidentally iterated though every object in the thang. The result was the standard Position, distance to, but with many, many more.
nearest = hero.findNearest(hero.findItems())
for item in nearest:
hero.say(item)
The result was this list: x, y, z, magnitude, heading, distance, dot, equals, copy, distanceSquared, rotate, add, subtract, multiply, divide, limit, normalize,
I happen to calculate the magnitude, distance-squared etc. a lot. It would be great if I could just call the data.
Can I get results from those elements? Is it possible, and if so how.
Once you beat the last mountain level you get the programmaticon V, it will give you access to Vector commands including Vector.distance and things like that.
CodeCombat provides a Vector class. You don’t actually need the Programmaticon V to access it, however.
hero.pos is a Vector. You can perform actions on it, should you want: hero.pos.add(new Vector(20, 20)). Of course, the hero’s position is immutable, so it only returns a new Vector of with the updated values.
Once you eat Summit’s Gate, then you can get the Programmaticon V which provides a better Vector reference, but if you want to see what the exact class is, now, look here:
Thanks a lot! I will use the class as is, but put a priority on beating the levels.
Edit*
Wow, having the vector class is amazing. Up to now I have had my own functions to add, subtract, and find the magnitude of functions. It takes bit of code just to get a single small unit vector. This is definitly a game changing aspect for me.