joligario
08-01-2009, 08:54 AM
2182 float Mob::GetReciprocalHeading(Mob* target) {
2183 float Result = 0;
2184
2185 if(target) {
2186 float h = target->GetHeading();
2187
2188 if(h > 0.0 && h < 128.0)
2189 Result = h + 128.0;
2190 else if(h > 128.0 && h < 256)
2191 Result = h - 128.0;
2192 else if(h == 128.0)
2193 Result = 255.9;
2194 else
2195 Result = h;
2196 }
2197
2198 return Result;
2199 }
Just a note for the author of this code:
First off, great idea! Just 2 questions, though. What if the heading is already 0.0 and wouldn't it be easier to just do a mod?
float Mob::GetReciprocalHeading(Mob* target) {
float Result = 0;
if(target) {
float h = target->GetHeading();
Result = (h + 128.0) % 256;
}
return Result;
}
2183 float Result = 0;
2184
2185 if(target) {
2186 float h = target->GetHeading();
2187
2188 if(h > 0.0 && h < 128.0)
2189 Result = h + 128.0;
2190 else if(h > 128.0 && h < 256)
2191 Result = h - 128.0;
2192 else if(h == 128.0)
2193 Result = 255.9;
2194 else
2195 Result = h;
2196 }
2197
2198 return Result;
2199 }
Just a note for the author of this code:
First off, great idea! Just 2 questions, though. What if the heading is already 0.0 and wouldn't it be easier to just do a mod?
float Mob::GetReciprocalHeading(Mob* target) {
float Result = 0;
if(target) {
float h = target->GetHeading();
Result = (h + 128.0) % 256;
}
return Result;
}