LayerDescription struct
#include <Jazz2/Tiles/LayerTypes.h>
Describes the configuration of a tile map layer.
Holds the parallax and rendering properties of a single layer — its depth, per-axis scroll and auto-scroll speeds, scroll offsets, repeat flags, speed models and the renderer type with its color parameter. One is stored in each TileMapLayer and drives how that layer is positioned and drawn relative to the camera.
Where the game places a layer for a view is worked out here rather than by the tile map, so it's the same without one — the preview of a level made when the level is converted (see Formats::
Public static variables
-
static std::
int32_t HardcodedOffset constexpr - Hardcoded offset for layer positioning.
- static float OriginalAutoSpeedScale constexpr
- How much further an auto speed of the original game moves a layer each frame than the same auto speed here.
Public static functions
-
static auto FromRecord(const Formats::
LayerRecord& record, std:: int32_t mainPlaneDepth) -> LayerDescription - Makes the description of a layer from a layer of a level file.
- static auto IsSpriteLayerRenderer(LayerRendererType type) -> bool
- Returns
trueif the sprite layer can be drawn with a renderer type. - static auto IsBehindBlend(LayerBlend blend) -> bool
- Returns
trueif a blend is computed with what is behind the layer, LayerBlend::Darken and those after it. -
static auto FromSpriteMode(std::
uint32_t spriteMode) -> LayerBlend - Returns the blend of a sprite mode of JJ2+ (
SPRITE::Mode) a layer can be drawn with, LayerBlend::Normal for any other. - static auto IsTexturedBackground(LayerRendererType type) -> bool
- Returns
trueif a renderer type is a textured background, LayerRendererType::Sky, LayerRendererType:: Tunnel, LayerRendererType:: TileMenu, LayerRendererType:: Wave or LayerRendererType:: Cylinder. - static auto FromOriginalAutoSpeed(float autoSpeed, LayerSpeedModel model) -> float
- Converts an auto speed of the original game or of JJ2+ to one of a layer, on an axis of a speed model.
- static auto ToOriginalAutoSpeed(float autoSpeed, LayerSpeedModel model) -> float
- Converts an auto speed of a layer back to one of the original game or of JJ2+, see FromOriginalAutoSpeed().
-
static auto TranslateCoordinate(float coordinate,
float speed,
float offset,
std::
int32_t viewSize, bool isY) -> float - Returns the coordinate of a layer of the default speed model at a coordinate of the view.
Public functions
-
void SetTexturedParams(const Formats::
TexturedLayerParams& params) - Takes the parameters of a tunnel, a wave, a cylinder or a reflection that the color has no room for.
- auto IsKeyedTileLayer() const -> bool
- Returns
trueif the layer is drawn as tiles that read what is behind them. - auto ReadsBehind() const -> bool
- Returns
trueif the layer may need a copy of what is behind it to be drawn. - auto HasInnerSurface() const -> bool
- Returns
trueif the texture of the layer is drawn only where the layer is placed as an ordinary one. - auto HasPlusPerspective() const -> bool
- Returns
trueif the texture of the layer is drawn in the perspective of JJ2+. - auto IsTexturePlacedByLayer5(bool vertical) const -> bool
- Returns
trueif the texture of a sky, a tunnel or a cylinder over the whole view is placed where layer 5 is on an axis. - auto GetGameplayOrigin(nCine::Vector2i layoutSize, nCine::Vector2i spriteLayoutSize, const nCine::Rectf& view) const -> nCine::Vector2f
- Returns where the tile (0, 0) of the layer is drawn in the level, as the game places it for a view.
- auto GetDrawOffsets(float viewHeight) const -> nCine::Vector2f
- Returns the offsets the layer is drawn with in a view of a height.
- auto GetViewCoordinates(nCine::Vector2i layoutSize, nCine::Vector2i spriteLayoutSize, const nCine::Rectf& placementRect, float loX, float loY) const -> nCine::Vector2f
- Returns the coordinates of the layer at the top left corner of the view it's placed by, minus HardcodedOffset.
Public variables
-
std::
uint16_t Depth - Layer depth (Z position).
- float SpeedX
- Horizontal speed.
- float SpeedY
- Vertical speed.
- float AutoSpeedX
- Horizontal auto speed.
- float AutoSpeedY
- Vertical auto speed.
- float OffsetX
- Horizontal scroll offset.
- float OffsetY
- Vertical scroll offset.
- bool RepeatX
- Whether layer should repeat horizontally.
- bool RepeatY
- Whether layer should repeat vertically.
- bool UseInherentOffset
- Whether inherent offset should be used, where it applies (see GetDrawOffsets()).
- LayerSpeedModel SpeedModelX
- Horizontal speed model.
- LayerSpeedModel SpeedModelY
- Vertical speed model.
- LayerRendererType RendererType
- Layer renderer type.
- nCine::Vector4f Color
- Layer color parameter.
- nCine::Vector2f TextureFadePosition
- Vanishing point and horizon of a sky, center of a tunnel or of the horizon of a cylinder, pivot of a tile menu, or the vanishing point and the horizon of a reflection, as a fraction of the view, the amplitudes of a wave.
-
std::
uint8_t TextureFade - Non-zero if a sky fades out into its horizon, a tunnel into its center or a cylinder into its horizon, the palette entry a reflection is tinted with.
-
std::
uint8_t TextureFlags - Combination of the flags of Formats::
TexturedLayerParams, whether a tunnel spirals, whether a cylinder is drawn at half size, which way the waves of a wave move and where a textured layer is drawn. - nCine::Vector2f TextureInnerSpeed
- Speeds of the texture of a textured layer drawn only where the layer is, against the view, see Formats::
TexturedLayerParams:: InnerSpeedX. - nCine::Vector2f TextureInnerAutoSpeed
- Speeds the texture of a textured layer drawn only where the layer is moves at by itself, see Formats::
TexturedLayerParams:: InnerAutoSpeedX. -
std::
uint8_t TextureMapping - One more than the index of the additional palette the texture of a textured layer is drawn through, see Formats::
TexturedLayerParams:: Mapping. - LayerBlend Blend
- How the layer is blended over what is behind it.
-
std::
uint8_t BlendParam - Opacity of a translucent, screened or multiplied layer, or the palette entry of the key of a textured background (see Blend).
Function documentation
static LayerDescription Jazz2:: Tiles:: LayerDescription:: FromRecord(const Formats:: LayerRecord& record,
std:: int32_t mainPlaneDepth)
Makes the description of a layer from a layer of a level file.
The depth of the layer is relative to mainPlaneDepth, the depth of the sprite layer's plane (see ILevelHandler::
static bool Jazz2:: Tiles:: LayerDescription:: IsSpriteLayerRenderer(LayerRendererType type)
Returns true if the sprite layer can be drawn with a renderer type.
Only those that draw each tile where it is — LayerRendererType::
static LayerBlend Jazz2:: Tiles:: LayerDescription:: FromSpriteMode(std:: uint32_t spriteMode)
Returns the blend of a sprite mode of JJ2+ (SPRITE::Mode) a layer can be drawn with, LayerBlend::
BLEND_DARKEN to BLEND_EXCLUSION, CHROMAKEY, and TRANSLUCENT, TRANSLUCENTTILE and BLEND_NORMAL (LayerBlend::
static bool Jazz2:: Tiles:: LayerDescription:: IsTexturedBackground(LayerRendererType type)
Returns true if a renderer type is a textured background, LayerRendererType::
A LayerRendererType::
static float Jazz2:: Tiles:: LayerDescription:: FromOriginalAutoSpeed(float autoSpeed,
LayerSpeedModel model)
Converts an auto speed of the original game or of JJ2+ to one of a layer, on an axis of a speed model.
Multiplied by OriginalAutoSpeedScale, so the layer moves as far each second as there. The auto speed of LayerSpeedModel::
void Jazz2:: Tiles:: LayerDescription:: SetTexturedParams(const Formats:: TexturedLayerParams& params)
Takes the parameters of a tunnel, a wave, a cylinder or a reflection that the color has no room for.
The level file stores them apart from the record of the layer (see Formats::
bool Jazz2:: Tiles:: LayerDescription:: IsKeyedTileLayer() const
Returns true if the layer is drawn as tiles that read what is behind them.
Only over a color of it (LayerBlend::
bool Jazz2:: Tiles:: LayerDescription:: ReadsBehind() const
Returns true if the layer may need a copy of what is behind it to be drawn.
A layer of tiles drawn by IsKeyedTileLayer(), and a textured background drawn translucent, keyed or by a blend mode from LayerBlend::
bool Jazz2:: Tiles:: LayerDescription:: HasInnerSurface() const
Returns true if the texture of the layer is drawn only where the layer is placed as an ordinary one.
A textured background other than a wave, or a reflection, with Formats::SURFACE::INNERWINDOW and INNERLAYER of JJ2+.
bool Jazz2:: Tiles:: LayerDescription:: HasPlusPerspective() const
Returns true if the texture of the layer is drawn in the perspective of JJ2+.
Over the whole view with Formats::
bool Jazz2:: Tiles:: LayerDescription:: IsTexturePlacedByLayer5(bool vertical) const
Returns true if the texture of a sky, a tunnel or a cylinder over the whole view is placed where layer 5 is on an axis.
In the perspective of JJ2+ (see HasPlusPerspective()) and with LayerSpeedModel::LAYERSPEEDMODEL::LAYER8 of JJ2+, the default of the sky layer of the original game. The texture then moves there only by its own auto speed, see TileMap::
nCine::Vector2f Jazz2:: Tiles:: LayerDescription:: GetGameplayOrigin(nCine::Vector2i layoutSize,
nCine::Vector2i spriteLayoutSize,
const nCine::Rectf& view) const
Returns where the tile (0, 0) of the layer is drawn in the level, as the game places it for a view.
layoutSize is the size of the layer and spriteLayoutSize the size of the sprite layer, both in tiles. A position in the level then lies on the tile (position - origin) / 32 of the layer, repeated if the layer repeats.
nCine::Vector2f Jazz2:: Tiles:: LayerDescription:: GetDrawOffsets(float viewHeight) const
Returns the offsets the layer is drawn with in a view of a height.
The offsets of the layer. The vertical one is less by the inherent offset where it applies, which moves the layer down by half of how much taller the view is than 200 pixels, as limitVisibleRegion of JJ2+ — only a layer of LayerSpeedModel::
nCine::Vector2f Jazz2:: Tiles:: LayerDescription:: GetViewCoordinates(nCine::Vector2i layoutSize,
nCine::Vector2i spriteLayoutSize,
const nCine::Rectf& placementRect,
float loX,
float loY) const
Returns the coordinates of the layer at the top left corner of the view it's placed by, minus HardcodedOffset.
The sizes are as in GetGameplayOrigin(), loX and loY are the offsets the layer is drawn with (see GetDrawOffsets()). On each axis, with the view starting at and long, the layer and the level pixels long, the speed , the auto speed and the offset , the layer coordinate at the start of the view is, by the speed model:
- LayerSpeedModel::
Default — , with half of how much longer the view is than 320 pixels horizontally and 200 vertically, so the layer meets the start of the level only at the speed of 1 or in a view of 320×200 - LayerSpeedModel::
FromStart — - LayerSpeedModel::
FitLevel — , where is how far the view is between the two ends of the level, clamped to 0 and 1 - LayerSpeedModel::
SpeedMultipliers — - LayerSpeedModel::
AlwaysOnTop — 0
That's where JJ2+ v6.6h places them, measured with Tests/Level/LayerProbe.j2as in three resolutions (see the TestLayerPlacement() of the editor self-test). The auto speed of the default model and of LayerSpeedModel::
Variable documentation
static float Jazz2:: Tiles:: LayerDescription:: OriginalAutoSpeedScale constexpr
How much further an auto speed of the original game moves a layer each frame than the same auto speed here.
The original game and JJ2+ move a layer by its auto speed each of their 70 ticks a second, a layer here moves by its auto speed each of the 60 frames a second (see TileMap::