Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - It_Helped_Me

Pages: [1]
1
Graphics / Determining whether a point lies within a non-rectangle shape
« on: November 30, 2023, 04:35:51 am »
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.


2
Graphics / Re: How Do I change background color of my window?
« on: November 05, 2023, 02:30:47 pm »
I literally just registered to this forum just so I can say this:
[...]
You are very welcome!
Welcome to the forum!
Thank you for helping the OP (from 2017); I'm sure this is exactly what they have been waiting for.

peep my username

Pages: [1]