YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

collision_triangle and/or collision_triangle_list function #4471

Open DragoniteSpam opened 9 months ago

DragoniteSpam commented 9 months ago

Is your feature request related to a problem?

Currently we have collision overlap functions for circles, ellipses, lines, points, and rectangles, plus _list functions to go with them. One shape that's notably missing is the triangle, not counting the point_in_triangle and rectangle_in_triangle functions. These would be useful to have for things like attacks that hit in a fan or view cones.

Describe the solution you'd like

collision_triangle and collision_triangle_list

Describe alternatives you've considered

Creating a triangle-shaped sprite and doing precise collision checks on it

Additional context

You can use point_direction or dot products to do view cones but most people who aren't mathy probably won't think about that and, in any case, collision_triangle_list would be one line of code vs like ten or twenty you'd need to filter for objects if you did it yourself

mistletoe commented 9 months ago

+1.

It'd also be nice to have a more-generic _collisionpolygon and _collision_polygonlist as well, that would take an array of points, have an optional concave solver (it's waaaay more expensive) and provide a useful error if the resultant polygon crosses line segments.