Friday 27 March 2009

Graphics and Lighting

I think I've really got my bit between the teeth at the moment when it comes to the development of this beast. Which is just as well as I've got an upcoming assignment (General Relativity and Electric and Magnetic Fields, natch) which will take a huge chunk of my time (weeks, in fact). I don't think I'll get Alpha 2 out before then, but things are well in hand.

One thing I'd like to add to Kharne in the meantime is ambient light in the dungeon, such as is currently being implemented in Umbrarum Regnum. Coding ambient light like this (dynamic lightsources is another matter) is not actually that complicated, if we assume lighting follows the standard field of view code.
  1. First, add an attribute (lets make this a real number) to every cell in the dungeon called "AmbientLightSource".
  2. Assign a cell as the light source itself.
  3. Using the Recursive FoV algorithm, calculate the FOV and write a value to this that depends on both the distance to the light source and the strength of the light source.
  4. The cell that contains the light source is assigned the strongest value.
  5. If two light sources overlap, we take the strongest value.
  6. During the display routine, adjust the brightness of the character to be displayed depending on the "AmbientLightSource" value.
  7. If cells contain ambient light, then items and monsters should be visible all the time, much like what happens in the players' view.
At some point, I'd like to go further and make lightsources spatially dynamic, so feasibly a) monsters could carry light sources and b) light sources could be extinguished or created (known in DnD terms as "cracking open a sunrod"). In any case, the basic graphical premise of Kharne would be unchanged: 1 standard ASCII character per "square", with all effects coming from changing colours and brightness.

No comments: