wyvern.lib.properties
Interface LightSource
- All Known Implementing Classes:
- SimpleLightSource
- public interface LightSource
This interface encapsulates much of the functionality of the
game's lighting model. Light sources in the game are independent
objects that "attach" to game objects to make them luminous.
- Version:
- 1.0, Feb 06, 1999
- Author:
- Steve Yegge
Method Summary |
int[][] |
getLightMatrix()
Returns the location list for the light source. |
Point |
getMatrixLocation()
Returns the (x,y) location of the upper-left corner of
the LightSource's local light matrix returned by calling
getLightMatrix(). |
void |
recompute()
Tells the light source to recompute its intensity matrix.
|
void |
remove()
Removes this light from its current map, if any. |
void |
setMap(GameMap map,
int x,
int y)
Tells the light which map to illuminate. |
getLightMatrix
public int[][] getLightMatrix()
- Returns the location list for the light source. The
light is typically centered in the array, although that's
not required, nor are there any constraints on the array
dimensions (e.g. it can be even by odd). The map will
take the array and "apply" it into the global array at
the (x,y) location returned by getMatrixLocation().
- Returns:
- the local array of integer intensities computed by
the LightSource. Each array value is added to (or subtracted
from, in the case where the LightSource is removed) the map.
An array value of zero thus has no effect, and LightSource
implementations can make use of this to return custom-shaped
illumination patterns.
getMatrixLocation
public Point getMatrixLocation()
- Returns the (x,y) location of the upper-left corner of
the LightSource's local light matrix returned by calling
getLightMatrix().
- Returns:
- the point in the map at which to apply the local
array. The LightSource has to know where it is in the
map anyway, so that it can call addLight() at the appropriate
location, not to mention compute its intensity array correctly
using the ray-caster utilities. Since the LightSource is in
complete control of where its light is displayed, it has to
tell the map where to apply its local intensity array; hence
this method.
recompute
public void recompute()
- Tells the light source to recompute its intensity matrix.
A square in the map has changed opacity, or some other event
has occurred that would cause the light's intensity matrix
to be invalid.
setMap
public void setMap(GameMap map,
int x,
int y)
- Tells the light which map to illuminate. This method causes
the light to call recompute(), which figures out its lighting
contribution and adds that contribution to the passed map.
- Parameters:
map
- the map to put the light inx
- map x locationy
- map y location
remove
public void remove()
- Removes this light from its current map, if any.