So im trying to return a vector2f from a function. So i can use it in a function in another class that takes a vector2f.
if i have the function
template <typename t, typename u>
sf::Vector2f checkDirection(std::vector<t> &vtower, std::vector<u> &vmonster)
{
for (int i = 0; i < vmonster.size(); i++)
{
for (int k = 0; k < vtower.size(); k++)
{
if (vmonster[i].getPositionX() + vmonster[i].getRadius() + vtower[k].getRadius() > vtower[k].getTowerRangePositionX()
&& vmonster[i].getPositionX() < vtower[k].getTowerRangePositionX() + vmonster[i].getRadius() + vtower[k].getRadius()
&& vmonster[i].getPositionY() + vmonster[i].getRadius() + vtower[k].getRadius() > vtower[k].getTowerRangePositionY()
&& vmonster[i].getPositionY() < vtower[k].getTowerRangePositionY() + vmonster[i].getRadius() + vtower[k].getRadius())
{
return direction(vmonster[i].getPositionX(), vmonster[i].getPositionY());
}
}
}
}
Im trying to return a vector2f so i can use it in this function here
for (int i = 0; i < bullet.size(); i++)
{
bullet[i].fire(function.checkDirection(myicetower, mymonsters)); //fire takes a vector2f
}