Line of Sight
Posted: Wed Feb 06, 2013 8:21 pm
Line of sight:
We must first define which tiles can be seen across and which tiles cannot. Currently the Walkable map layer defines which tiles can be walked on and which cannot.
Optionally, it should be relatively simple to add a third category of tiles that can be seen across but not walked across (e.g. small plants and boulders, tree stumps). I think we can skip the possibility of a tile that can be walked across but not seen across, although one can imagine special cases ... magical veils, dense spider webs... But one thing at a time.
I'll investigate the code to see if it is as simple as adding a new color code to the Walkable layer. If not, then a separate Seeable layer could be created, but that's alot more work.
Also, the actual line of sight rules need to be determined. My first cut idea is that any tile is visible from the player's position tile if the line connecting the two tile centers does not pass through a vision-blocking tile. I could code and test this rule to see if the resulting lines of sight seem realistic.
This setup could be used for:
1) Changing the map display to account for partial lighting, such as a stationary candelabra that only lights part of a room, or a player-carried torch. LOS defines which tiles are lit, within range of the light if applicable.
2) Revealing only the part of a map, based on what the player can actually see. This could attract both the display of the main screen and the world map. Tiles that have never been in the player's LOS (while lit) would remain black.
3) Implementing ranged weapons and/or spells. Only a visible tile can be targeted. Optionally, we could allow a player indoors to shoot at an unlit tile, but the projectile would only get there if the target tile would be in LOS in full light.
All of this would require some upgrades to the data structure for the maps and the map display routine, but should be doable.
Any comments?
We must first define which tiles can be seen across and which tiles cannot. Currently the Walkable map layer defines which tiles can be walked on and which cannot.
Optionally, it should be relatively simple to add a third category of tiles that can be seen across but not walked across (e.g. small plants and boulders, tree stumps). I think we can skip the possibility of a tile that can be walked across but not seen across, although one can imagine special cases ... magical veils, dense spider webs... But one thing at a time.
I'll investigate the code to see if it is as simple as adding a new color code to the Walkable layer. If not, then a separate Seeable layer could be created, but that's alot more work.
Also, the actual line of sight rules need to be determined. My first cut idea is that any tile is visible from the player's position tile if the line connecting the two tile centers does not pass through a vision-blocking tile. I could code and test this rule to see if the resulting lines of sight seem realistic.
This setup could be used for:
1) Changing the map display to account for partial lighting, such as a stationary candelabra that only lights part of a room, or a player-carried torch. LOS defines which tiles are lit, within range of the light if applicable.
2) Revealing only the part of a map, based on what the player can actually see. This could attract both the display of the main screen and the world map. Tiles that have never been in the player's LOS (while lit) would remain black.
3) Implementing ranged weapons and/or spells. Only a visible tile can be targeted. Optionally, we could allow a player indoors to shoot at an unlit tile, but the projectile would only get there if the target tile would be in LOS in full light.
All of this would require some upgrades to the data structure for the maps and the map display routine, but should be doable.
Any comments?