diff --git a/src/colony.cpp b/src/colony.cpp new file mode 100644 index 0000000..a8b2efd --- /dev/null +++ b/src/colony.cpp @@ -0,0 +1,15 @@ +#include "colony.hpp" +#include "ant.hpp" + +Colony::Colony(double x, double y) + : x(x), y(y) { + appearance = sf::CircleShape(25); + appearance.setFillColor(sf::Color::Red); + appearance.setPosition(x - appearance.getRadius(), y - appearance.getRadius()); +} + +// TODO: don't use appearance for this, add radius field +bool Colony::antIsHome(const Ant& ant) const { + return ant.x > x - appearance.getRadius() && ant.x < x + appearance.getRadius() + && ant.y > y - appearance.getRadius() && ant.y < y + appearance.getRadius(); +} diff --git a/src/colony.hpp b/src/colony.hpp new file mode 100644 index 0000000..032535f --- /dev/null +++ b/src/colony.hpp @@ -0,0 +1,20 @@ +#ifndef __COLONY_H_ +#define __COLONY_H_ + +#include + +class Ant; // Colony and Ant can't include eachother so forward-declare + +class Colony { + double x, y; + +public: + sf::CircleShape appearance; + +public: + Colony(double x, double y); + + bool antIsHome(const Ant& ant) const; +}; + +#endif // __COLONY_H_