Line Of Sight

I thought I’d write a bit on the line of sight system I’ve written for Rhenium.  It was one of the most important features that I wanted to prototyping early in the development of the project as I knew other aspects may vary or change this would be one of the fundamental elements that would make game-play more interesting.  I started reading concepts and implementations for line of sight systems and there are some notable starting points out there such as RogueBasin and started looking at writing something similar to the ideas I was learning about within my project.  Sure enough my game now hid and displayed walls and pathways correctly in relation to the player and the effect was immediately satisfying but it didn’t take long before I started hitting performance problems.  The possibility that algorithms serving turn-based rogue-likes might not perform too well in a real-time action game had been on my mind the whole time but I had to run those ideas myself, start pushing the limits of what I could do, find the bottlenecks, and see if I could solve those things to make it sweet in real-time.  That part took weeks of effort and, while there are probably better real-time solutions that have been achieved, I didn’t quite find what I was looking for so and so had to figure the problems out alone.  In the end I used some ideas that helped dramatically improve performance to the point where a number of unique line of sight processes can be running on screen together for a team of players in real time.  The key here was to study solutions, and think through how to improve performance specifically for my game and no other purpose, and just iterate that process a little.  Something like line of sight will always have a system impact, especially in a real time tile based game, just because of the number of calculations but there’s a lot you can do to improve performance for your aims.

The line of sight system as it functions now will keep a tile’s last known state in memory ‘as you saw it’ before it’s visibility becomes obstructed.  This means that as a player moves around a level they build up a picture of areas of the map but it is always the state as they saw it before their line of sight moved away and so cannot be depended on.  Any event outside of the player’s field of view (for example, an enemy tunnelling through a wall) will not be apparent until they can see it for themselves.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s