I have a problem: I need an algorithm for my tile engine.
I have an 2d-array which stores my un-walkable tiles.
Now I want to implement a light engine, but this engine need shadow-hulls.
So I need an algorithm which will create these shadow-hulls.
I need a set of rectangles that bound the un-walkable portions of the array (the cells that have 1
s)
For example:
The black tile are 1
s; I need to find the set of red rectangles that fully enclose them.
Try something like this:
Create a list containing every desired point. (In your case, the coordinates of every 1
)
For each point in this list:
0
)0
at any Y value between the point and the ending Y coordinate you got from step 1.This probably isn't the fastest way to do this, but it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With