I'm doing a bit of trial and error with Flash/AS3 and Flixel to make a car move to various waypoints on its own. Anyway I have found some code by Microsoft for XNA/C# and am trying to convert it but am stuck on two bits to do with vectors...
location = location + (Direction *
MoveSpeed * elapsedTime);
"location" is a Vector2.
Similarly:
tank.Location + (orth * t开发者_如何学PythonurningRadius)
".Location" and "orth" are also both Vector2's.
Can anybody tell me what this is actually doing?
I don't understand how you can add or multiply a single number to a Vector2 but maybe I am missing something obvious!!
Cheers
Chris
The compiler is doing some nice things for you. In effect what the code is doing is this:
location.X += (orth.X * turningRadius);
location.Y += (orth.Y * turningRadius);
A quick and simple vector math intro: http://johnnygizmo.blogspot.com/2008/10/xna-sidebar-intro-to-vector-math.html
精彩评论