|Topic was automatically imported from the old Question2Answer platform.
|Allen Kennedy Jr.
Here’s the scenario. I want to have a grid based game, like a roguelike where you don’t see anything to start. When the player is placed, he can see the room he is in and the walls of it, As the player moves through doors and hallways, they each uncover themselves on the map.
This is a very common feature of roguelikes and dungeon crawlers. where you can only see what the player character has been able to see.
I’m trying to do with with 2 tilemaps. The first map has the floors and walls. The second map has only black tile covering everything.
I was thinking shadow casting was probably the solution, where every time the player moves, you clear the black tilemap grid cell based on what is hit from the shadow cast. Implimentation of this is non-trivial to say the least. Requiring manual line algorithms, and complex vector math.
So, I fooled with that for a while and gave up because all the resources on the web gloss over the real details, “Just use the front facing edges” or “figure out which vertex is closest” with no explanation how to do those things.
Currently I’m trying to cast a ray to each of the 4 corners of every tile in the map, and where it hits, I uncover. This is good for the walls, but I haven’t yet figured out how to uncover the floor. That is, how to find all the cells from the player character to the ray collision point. I thought about creating a polygon, and checking if each cell is in the polygon, but Polygon2d doesn’t have a “has_point” function… so I’m stuck.
Am I going down the wrong path all together? Am I making this harder than it needs to be? Or Do all Roguelike devs deal with this crap?