Day 3-4

Today and yesterday I've implemented a visibility system with fog of war, i.e. you must first discover parts of the map to see them and you can only see entities that your character could actually see. I was actually surprised at how well my very naive implementation of this worked.

Essentially, to compute visibility, I just iterate all tiles in a circle around my character and use Bresenham's line drawing algorithm to draw a line to each square. If the line intersects a wall, that tile is not visible. If it doesn't, that tile is visible. This works really well aside from some tiles that are strangely disconnected in visibility because the lines produced by the algorithm just happened to avoid all the walls. But it works well enough, so I will not dwell on it further.

I've also implemented a simple combat system, hp bars, and I've had my first emergent behaviour: A goblin killed a rat to get closer to me. :P

Visibility System