Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Entity {
- public:
- int x, y;
- bool alive;
- // Distance squared
- inline int distance2 (const Entity &e) {
- return (x - e.x)*(x - e.x) + (y - e.y)*(y - e.y);
- }
- // Distance square rooted
- inline float distance (Entity *e) {
- return sqrt(distance2(*e));
- }
- inline float distance (int value) {
- return sqrt(value);
- }
- // Distance squared from given point
- inline int distance2 (int _x, int _y) {
- return (x - _x)*(x - _x) + (y - _y)*(y - _y);
- }
- // Distance square from given point
- inline float distance (int _x, int _y) {
- return sqrt(distance2(_x,_y));
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement