* Checks whether a point is inside the selected a diagonal rectangle given by _thd.size and _thd.pos * @param x The x coordinate of the point to be checked. * @param y The y coordinate of the point to be checked. * @return True if the point is inside the rectangle, else false. */
| 799 | * @return True if the point is inside the rectangle, else false. |
| 800 | */ |
| 801 | bool IsInsideRotatedRectangle(int x, int y) |
| 802 | { |
| 803 | int dist_a = (_thd.size.x + _thd.size.y); // Rotated coordinate system for selected rectangle. |
| 804 | int dist_b = (_thd.size.x - _thd.size.y); // We don't have to divide by 2. It's all relative! |
| 805 | int a = ((x - _thd.pos.x) + (y - _thd.pos.y)); // Rotated coordinate system for the point under scrutiny. |
| 806 | int b = ((x - _thd.pos.x) - (y - _thd.pos.y)); |
| 807 | |
| 808 | /* Check if a and b are between 0 and dist_a or dist_b respectively. */ |
| 809 | return IsInRangeInclusive(dist_a, 0, a) && IsInRangeInclusive(dist_b, 0, b); |
| 810 | } |
| 811 | |
| 812 | /** |
| 813 | * Add a child sprite to a parent sprite. |
no test coverage detected