I’m back after a 10 day pause. Yes, I’ve somehow managed to survive this period of time without coding. I was busy practicing for my german language exam and I played a little bit an extraordinary ascii (what a coincidence) rpg game called “Candy Box 2”.
The funny thing is, while I was doing some research how to implement the FOV algorithms, and how to procedurally generate levels, I’ve stumbled upon a game genre that was invented in the eighties and I (an experienced gamer) didn’t have a clue about it. “Rogue-like” games. I never heard that term before. So my idea of making first a ascii version of my game, wasn’t so original after all.
Enough talk… let’s get back to the FOV. It looks nice, but there’s still that third step missing we’ve talked about (seeing only tiles in front of the unit). That’s easy to implement for the unit’s basic headings (north, south, east, west). What about 45 degree headings (north-east, south-east, north-west, south-west)? The answer is simple and can be achieved with a little bit of advanced mathematics. We extend our origin (unit’s current position) in both directions diagonally with a length of our FOV (radius) divided by two, and get two origin points instead of one (the original origin is in the middle of the line between these two new points). Then we simply calculate the cross product with the third point which is our tile position that we are testing.
To test this third step, I created a new mock map which contains only passable (visible) tiles.
