public class SubcellLayers extends SparseLayers
DungeonUtility.generateResistances3x3(char[][])
(this looks better if it is given
a "line" dungeon as produced by DungeonUtility.hashesToLines(char[][], boolean)
),
and then you can use that resistance map with normal FOV methods, just typically at triple vision range. Much of the
time, it makes sense to run both that triple-range FOV, and a normal-range FOV with a resistance map calculated in
cells; you can use the normal-range FOV for gameplay and AI calculations and the triple-range for visual display.
animationCount, backgrounds, defaultBackground, defaultForeground, defaultPackedBackground, defaultPackedForeground, font, glyphs, gridHeight, gridWidth, layers, mapping, scc
Constructor and Description |
---|
SubcellLayers(int gridWidth,
int gridHeight) |
SubcellLayers(int gridWidth,
int gridHeight,
float cellWidth,
float cellHeight) |
SubcellLayers(int gridWidth,
int gridHeight,
float cellWidth,
float cellHeight,
TextCellFactory font) |
SubcellLayers(int gridWidth,
int gridHeight,
float cellWidth,
float cellHeight,
TextCellFactory font,
float xOffset,
float yOffset) |
Modifier and Type | Method and Description |
---|---|
void |
blend(int x,
int y,
float color,
float mixBy)
Using the existing background color at the subcell position x,y, this performs color blending from that existing
color to the given color (as a float), using the mixBy parameter to determine how much of the color parameter to
use (1f will set the color in this to the parameter, while 0f for mixBy will ignore the color parameter
entirely).
|
void |
clear(int x,
int y)
Removes the foreground chars, where present, in all layers at the given x,y position.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float parentAlpha)
Draws the SubcellLayers and all glyphs it tracks.
|
void |
fillArea(com.badlogic.gdx.graphics.Color color,
int x,
int y,
int width,
int height)
Changes the background color in an area to all have the given color, as a libGDX Color (or SColor, etc.).
|
void |
fillArea(float color,
int x,
int y,
int width,
int height)
Changes the background color in an area to all have the given color, as a packed float.
|
void |
put(char[][] chars,
com.badlogic.gdx.graphics.Color[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also
setting the background colors to match the given Color 2D array.
|
void |
put(char[][] chars,
com.badlogic.gdx.graphics.Color[][] fgColors,
com.badlogic.gdx.graphics.Color[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first Color 2D array,
starting at x=0, y=0, while also setting the background colors to match the second Color 2D array.
|
void |
put(char[][] chars,
float[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also
setting the background colors to match the given 2D array of colors as packed floats.
|
void |
put(char[][] chars,
float[][] fgColors,
float[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first float 2D array,
starting at x=0, y=0, while also setting the background colors to match the second float 2D array.
|
void |
put(com.badlogic.gdx.graphics.Color[][] colors)
Sets the background colors to match the given Color 2D array.
|
void |
put(float[][] colors)
Sets the background colors to match the given 2D array of colors as packed floats.
|
void |
put(int x,
int y,
char c,
com.badlogic.gdx.graphics.Color foreground,
com.badlogic.gdx.graphics.Color background)
Puts the char c at the position x,y with the given foreground and background colors.
|
void |
put(int x,
int y,
char c,
com.badlogic.gdx.graphics.Color foreground,
com.badlogic.gdx.graphics.Color background,
int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors.
|
void |
put(int x,
int y,
char c,
float foreground,
float background)
Puts the char c at the position x,y with the given foreground and background colors as encoded floats, such as
those produced by
Color.toFloatBits() . |
void |
put(int x,
int y,
char c,
float foreground,
float background,
int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors as
encoded floats, such as those produced by
Color.toFloatBits() . |
void |
put(int x,
int y,
com.badlogic.gdx.graphics.Color color)
Changes the background at position x,y to the given Color.
|
void |
put(int x,
int y,
float bg)
Changes the background at position x,y to the given color as an encoded float.
|
void |
put(int x,
int y,
java.lang.String text,
com.badlogic.gdx.graphics.Color foreground,
com.badlogic.gdx.graphics.Color background)
Puts text at the position x,y with the given foreground and background colors.
|
void |
put(int x,
int y,
java.lang.String text,
com.badlogic.gdx.graphics.Color foreground,
com.badlogic.gdx.graphics.Color background,
int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors.
|
void |
put(int x,
int y,
java.lang.String text,
float foreground,
float background)
Puts text at the position x,y with the given foreground and background colors as encoded floats, such as
those produced by
Color.toFloatBits() . |
void |
put(int x,
int y,
java.lang.String text,
float foreground,
float background,
int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors as encoded
floats, such as those produced by
Color.toFloatBits() . |
void |
putSingle(int x,
int y,
float color)
Sets a single subcell of the background to use the specified color as a packed float.
|
void |
putWithConsistentLight(int x,
int y,
com.badlogic.gdx.graphics.Color background,
com.badlogic.gdx.graphics.Color lightColor,
float lightAmount,
float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific
amount, without putting a char on the screen; as a whole this affects one x,y position.
|
void |
putWithConsistentLight(int x,
int y,
float background,
float lightColor,
float lightAmount,
float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific
amount, without putting a char on the screen; as a whole this affects one x,y position.
|
void |
putWithLight(int x,
int y,
com.badlogic.gdx.graphics.Color background,
com.badlogic.gdx.graphics.Color lightColor,
float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific
amount, without putting a char on the screen; as a whole this affects one x,y position.
|
void |
putWithLight(int x,
int y,
float background,
float lightColor,
float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific
amount, without putting a char on the screen; as a whole this affects one x,y position.
|
void |
tint(float delay,
int x,
int y,
float encodedColor,
float duration,
java.lang.Runnable postRunnable)
Tints the background at position x,y (in cells) so it becomes the given encodedColor, waiting for
delay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color,
taking duration seconds. |
addLayer, addLayer, bump, bump, burst, burst, burst, burst, calculateConsistentLightAmount, calculateConsistentLightModifier, calculateConsistentLightModifier, cellHeight, cellWidth, clear, clear, clear, fillBackground, fillBackground, findLayer, frontChars, frontChars, getBackgrounds, getColorCenter, getDefaultBackgroundColor, getDefaultForegroundColor, getFont, getGridHeight, getGridWidth, getLayer, getLayerCount, getScc, glyph, glyph, glyphFromGrid, glyphFromGrid, gridHeight, gridWidth, gridX, gridY, hasActiveAnimations, put, put, put, put, put, put, put, putBorders, putBordersCaptioned, putChars, putChars, putChars, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithConsistentLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseConsistentLight, putWithReverseLight, putWithReverseLight, recallToGrid, recallToGrid, recolor, recolor, recolor, recolor, recolor, recolor, recolor, recolor, removeGlyph, setBackgrounds, setColorCenter, setDefaultBackground, setDefaultForeground, setFont, setLayer, setScc, setTextSize, slide, slide, summon, summon, summon, summon, tint, tint, tint, tint, tint, tint, tint, wiggle, wiggle, worldX, worldY
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
public SubcellLayers(int gridWidth, int gridHeight)
public SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight)
public SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font)
public SubcellLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)
public void put(char[][] chars, com.badlogic.gdx.graphics.Color[][] colors)
SparseLayers.gridWidth
and a height that is 3 * SparseLayers.gridHeight
. If the colors argument is null, does not
affect backgrounds but may still affect chars. If the chars argument is null, only affects the background colors.
This will filter each Color in colors if the color center this uses has a filter.put
in interface IPackedColorPanel
put
in class SparseLayers
chars
- Can be null
, indicating that only colors must be put.colors
- the background colors for the given chars; this array should have 3 times the width and height of charspublic void put(char[][] chars, float[][] colors)
SparseLayers.gridWidth
and a height that is 3 * SparseLayers.gridHeight
. If the colors argument
is null, does not affect backgrounds but may still affect chars. If the chars argument is null, only affects the
background colors. This will not filter the passed colors at all.put
in class SparseLayers
chars
- Can be null
, indicating that only colors must be put.colors
- the background colors for the given chars; this array should have 3 times the width and height of charspublic void put(char[][] chars, com.badlogic.gdx.graphics.Color[][] fgColors, com.badlogic.gdx.graphics.Color[][] bgColors)
put
in class SparseLayers
chars
- Can be null
, indicating that only colors must be put.fgColors
- the foreground Colors for the given charsbgColors
- the background Colors for the given chars; this array should have 3 times the width and height of charspublic void put(char[][] chars, float[][] fgColors, float[][] bgColors)
put
in class SparseLayers
chars
- Can be null
, indicating that only colors must be put.fgColors
- the foreground colors for the given chars, as packed floatsbgColors
- the background colors for the given chars, as packed floats; this array should have 3 times the width and height of charspublic void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
SparseLayers.setScc(IColorCenter)
.put
in class SparseLayers
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null, nothing will change in the backgroundpublic void put(int x, int y, char c, float foreground, float background)
Color.toFloatBits()
. If foreground is 0f, then this does not
change the foreground contents. If background is 0f, this does not change the background. Does not filter the
given colors.put
in class SparseLayers
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundpublic void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
SparseLayers.setColorCenter(IColorCenter)
. The layer can be greater than the number of layers currently present,
which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not
change. It is recommended that to add a layer, you only add at the value equal to SparseLayers.getLayerCount()
, which
will maintain the order and layer numbers in a sane way.put
in class SparseLayers
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 and SparseLayers.getLayerCount()
inclusivepublic void put(int x, int y, char c, float foreground, float background, int layer)
Color.toFloatBits()
. If foreground is 0f, then this does not
change the foreground contents. If background is 0f, this does not change the
background. Does not filter the given colors. The layer can be greater than the number of layers currently
present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer
will not change. It is recommended that to add a layer, you only add at the value equal to
SparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a sane way.put
in class SparseLayers
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 and SparseLayers.getLayerCount()
inclusivepublic void put(int x, int y, java.lang.String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
SparseLayers.setColorCenter(IColorCenter)
.put
in class SparseLayers
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundpublic void put(int x, int y, java.lang.String text, float foreground, float background)
Color.toFloatBits()
. If foreground is 0f, then this does not change the foreground
contents. If background is 0f, this does not change the background. Does not filter the given colors.put
in class SparseLayers
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundpublic void put(int x, int y, java.lang.String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
SparseLayers.setColorCenter(IColorCenter)
. The layer
can be greater than the number of layers currently present, which will add a layer to be rendered over the
existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer,
you only add at the value equal to SparseLayers.getLayerCount()
, which will maintain the order and layer numbers in a
sane way.put
in class SparseLayers
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 and SparseLayers.getLayerCount()
inclusivepublic void put(int x, int y, java.lang.String text, float foreground, float background, int layer)
Color.toFloatBits()
. If foreground is 0f, then this does not change the
foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.
The layer can be greater than the number of layers currently present, which will add a layer to be rendered over
the existing layers, but the number that refers to that layer will not change. It is recommended that to add a
layer, you only add at the value equal to SparseLayers.getLayerCount()
, which will maintain the order and layer
numbers in a sane way.put
in class SparseLayers
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 and SparseLayers.getLayerCount()
inclusivepublic void put(int x, int y, com.badlogic.gdx.graphics.Color color)
put
in interface IPackedColorPanel
put
in class SparseLayers
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatecolor
- the Color to change to; if null will be considered fully transparentpublic void put(int x, int y, float bg)
put
in interface IPackedColorPanel
put
in class SparseLayers
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatebg
- the color, as an encoded float, to change to; may be transparent, and considers 0f a valid colorpublic void putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
putWithLight
in class SparseLayers
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limitedpublic void putWithLight(int x, int y, float background, float lightColor, float lightAmount)
putWithLight
in class SparseLayers
x
- the x position, in subcells (3 subcells in a row have the width of one character cell)y
- the y position, in subcells (3 subcells in a column have the height of one character cell)background
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a float that determines how much lightColor should affect background by; not strictly limitedpublic void putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount, float flickerSpeed)
FOV
class, then all cells
at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.putWithConsistentLight
in class SparseLayers
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited
to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005fpublic void putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)
FOV
class, then all cells
at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.putWithConsistentLight
in class SparseLayers
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited
to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005fpublic void putSingle(int x, int y, float color)
put(int, int, char, float, float)
at the position x=20,y=30, this would set that subcell at
x=20*3+1,y=30*3+1 , where the *3 gets the x and y to refer to the correct 3x3 subcell grid, and the +1 chooses
the subcell as one to the right and one down.x
- the x position in the triple-width, triple-height grid of background subcellsy
- the y position in the triple-width, triple-height grid of background subcellscolor
- a packed float color to place in the background of one subcellpublic void put(com.badlogic.gdx.graphics.Color[][] colors)
SparseLayers.gridWidth
and a height that is 3 * SparseLayers.gridHeight
. If the colors argument is null, does nothing.
This will filter each Color in colors if the color center this uses has a filter.put
in class SparseLayers
colors
- the background colors for the given charspublic void put(float[][] colors)
SparseLayers.gridWidth
and a height that is 3 * SparseLayers.gridHeight
. If the colors argument
is null, does nothing. This will not filter the passed colors at all.put
in class SparseLayers
colors
- the background colors to use for this SparseLayerspublic void clear(int x, int y)
clear
in interface IPackedColorPanel
clear
in class SparseLayers
x
- the x-coordinate of the position to remove all chars fromy
- the y-coordinate of the position to remove all chars frompublic void fillArea(com.badlogic.gdx.graphics.Color color, int x, int y, int width, int height)
SparseLayers.gridWidth
and the grid height in subcells is 3 * SparseLayers.gridHeight
. To affect a full cell, this
needs a width and height of at least 3 each; anything less will affect only some subcells.fillArea
in class SparseLayers
color
- a libGDX Color to fill the area with; may be null to make the background transparentx
- left edge's x coordinate, in subcells (3 subcells to one cell horizontally)y
- top edge's y coordinate, in subcells (3 subcells to one cell vertically)width
- the width of the area to change the color on, in subcells (3 subcells to one cell horizontally)height
- the height of the area to change the color on, in subcells (3 subcells to one cell vertically)public void fillArea(float color, int x, int y, int width, int height)
SparseLayers.gridWidth
and the grid height in subcells is 3 * SparseLayers.gridHeight
. To affect a full cell, this
needs a width and height of at least 3 each; anything less will affect only some subcells.fillArea
in class SparseLayers
color
- a color as a packed float to fill the area with; may be 0f to make the background transparentx
- left edge's x coordinate, in subcells (3 subcells to one cell horizontally)y
- top edge's y coordinate, in subcells (3 subcells to one cell vertically)width
- the width of the area to change the color on, in subcells (3 subcells to one cell horizontally)height
- the height of the area to change the color on, in subcells (3 subcells to one cell vertically)public void blend(int x, int y, float color, float mixBy)
blend
in interface IPackedColorPanel
blend
in class SparseLayers
x
- the x component of the position in this panel to draw the starting color fromy
- the y component of the position in this panel to draw the starting color fromcolor
- the new color to mix with the starting color; a packed float, as made by Color.toFloatBits()
mixBy
- the amount by which the new color will affect the old one, between 0 (no effect) and 1 (overwrite)public void tint(float delay, int x, int y, float encodedColor, float duration, java.lang.Runnable postRunnable)
delay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color,
taking duration seconds. Additionally, enqueue postRunnable
for running after the created action ends.
All subcells in the tinted cell will reach the same color during this animation, but the subcells can start with
different colors, and they will return to those starting colors after this animation finishes.
Stage.act()
before you call Stage.draw()
, but after
any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will
draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite
the tint in the next frame. That visually appears as nothing happening other than a delay.tint
in class SparseLayers
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in secondspostRunnable
- a Runnable to execute after the tint completes; may be null to do nothing.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
Batch.begin()
must have already been called on the
batch, and Batch.end()
should be called after this returns and before the rendering code finishes for the
frame.
batch
if using a distance field or MSDF font and the shader is currently not
configured for such a font; it does not reset the shader to the default so that multiple Actors can all use the
same shader and so specific extra glyphs or other items can be rendered after calling draw(). If you need to draw
both a distance field font and full-color art, you should set the shader on the Batch to null when you want to
draw full-color art, and end the Batch between drawing this object and the other art.draw
in class SparseLayers
batch
- a Batch such as a FilterBatch
that must be between a begin() and end() call; usually done by StageparentAlpha
- currently ignoredCopyright © Eben Howard 2012–2022. All rights reserved.