ACk! I just noticed that there is an instance of 'direction' in the getY method. This should be velocity. -eek! NOt sure how that got in there, but there ya go! :)

## Advertising

-Good thing I reread these! lol! Smiles, Cara :) On Dec 11, 2010, at 10:22 AM, Cara Quinn wrote: Hi Thomas; I'll comment and adapt your code below. These methods should all return normal vectors anyway, so you shouldn't need to normalize. I just did a few tweaks as that's all they seem to need. changed z to y for consistency. Let me know how it goes, K?… Smiles, Cara :) On Dec 9, 2010, at 7:22 PM, Thomas Ward wrote: Hi Cara, Sure no problem. below is the functions I'm using to calculate the angle and vector Mara will travel to reach her next coordinates on the map. However, before you ask the reason the calculations don't have a fps or time parameter that's because I assume 1 as the frames per second which is a slow frame rate I know. Here goes. // Name: GetDirection (double, double, double, double). // Description: Calculates the angle between // two game objects. // CQ // will switch your z to y so i can think straight :) float Calculate::GetDirection (double x1, double y1, double x2, double y2) { // CQ // changing this so both subtractions are in the same order // as this changes the result // Subtract x1 from x2 double x = x2 - x1; // Subtract y1 from y2 double y = y2 - y1; // CQ // this should be y over x // Calculate theta by the arc tangent // of -y/x double theta = std::atan2 (y,x); // Now, multiply theta by 180 // and divide by PI double direction = (theta * 180) / PI; // Return the direction return (float)direction; } // Name: GetX(double, double, double). // Description: Calculates the next possible x component. float Calculate::GetX (double direction, double x, double velocity) { // Calculate the next x component by // multiplying velocity by the cosine of // direction*PI/180 // CQ // switched this to cos and changed calculation slightly x = velocity * std::cos ((direction * PI) / 180)); // Return the new x component return (float)x; } // Name: GetY(double, double, double). // Description: Calculates the next possible y component. float Calculate::GetY (double direction, double y, double velocity) { // Calculate the next y component by // multiplying velocity by the sine of // direction*PI/180 y = velocity * std::sin ((direction * PI) / 180); // Return the new y component return (float)y; } --- Gamers mailing list __ Gamers@audyssey.org If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org. You can make changes or update your subscription via the web, at http://audyssey.org/mailman/listinfo/gamers_audyssey.org. All messages are archived and can be searched and read at http://www.mail-archive.com/gam...@audyssey.org. If you have any questions or concerns regarding the management of the list, please send E-mail to gamers-ow...@audyssey.org. --- Gamers mailing list __ Gamers@audyssey.org If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org. You can make changes or update your subscription via the web, at http://audyssey.org/mailman/listinfo/gamers_audyssey.org. All messages are archived and can be searched and read at http://www.mail-archive.com/gam...@audyssey.org. If you have any questions or concerns regarding the management of the list, please send E-mail to gamers-ow...@audyssey.org.