yupplemayham/YuppleMayham/include/utility/direction.h
Ethan Adams 3075a01b3d Sorted header files under include
made Script base class for AIScript and eventually WeaponScript
2024-06-22 23:01:50 -04:00

28 lines
No EOL
657 B
C++

#ifndef _H_DIRECTION_H
#define _H_DIRECTION_H
#include <cmath>
enum class Direction {
Down = 1,
Right = 2,
Left = 3,
Up = 4
};
static Direction getDirectionFromRotation(float rotation) {
double normalizedRot = std::fmod(rotation + 360, 360);
if ((normalizedRot >= 337.5) || (normalizedRot < 22.5))
return Direction::Right;
else if ((normalizedRot >= 22.5) && (normalizedRot < 157.5))
return Direction::Down;
else if ((normalizedRot >= 157.5) && (normalizedRot < 247.5))
return Direction::Left;
else if ((normalizedRot >= 247.5) && (normalizedRot < 337.5))
return Direction::Up;
return Direction::Down;
}
#endif // _H_DIRECTION_H