Greetings,
How do I test in an update function whether a sf::Vector2f is in a certain radius around another sf::Vector2f?
As I understand it, calculate the distance between them and check whether it is smaller or equal to the radius? Distance formula d = sqrt( (x2-x1)² + (y2-y1)² ) correct?
I kinda have problems managing all entities/towers etc. though. Say I detect an entity in radius, I still get problems finding/using the entity afterwards, like "Great, which one was it again?"
But then, how do I know how to rotate, so my tower faces a player given the players position and towers position? (I have a graphic which illustrates what I am trying to achieve).
So I have a tower (which has sprite) and a player (which has sprite) and I want to rotate the tower accordingly, while the player is in range (say I could maybe figure this part out by myself).
P.S.:
I have the thor vectorAlgebra2D library at hand, if it helps. Couldn't find a distance function though
Sorry for seeming like a "noob" in video game terms, I try to do as much as possible by myself, but sometimes you just can't get further for some reason
Raincode