Hello everyone, hope you're doing well. I've been using SFML for school a few months now, and I'm working on a grid-based strategy role-playing game (like Fire Emblem, Shining Force, etc.) for my class. If you've played such a game, you know that when choosing to move, attack, etc. it highlights the tiles within a certain star-shaped radius (see attached example). I'm trying to implement a function that does this.
In my current approach, I made a square RectangleShape the size of the other squares in the grid, times the desired radius, plus a very small amount. I then set the origin of this square to the position of the character and rotate it 45 degrees. I've drawn it out on graph paper, and the resulting diamond will include the top left of every square I'd want to highlight.
I have a function that uses the getGlobalBounds() of the diamond to highlight every square on the grid whose position is within the diamond. But it highlights a large square around the character, not the shape I'm aiming for. I know this is because getGlobalBounds() returns the bounding rectangle of the shape, but I thought the bounding rectangle would rotate with the shape, which I now see is not the case.
So is there a way to do what I'm actually trying to do, which is: check if certain coordinates are within a non-rectangle shape?
Any help would be greatly appreciated. Thank you for reading.