joka.game
The game module provides game related types and functions.
Types 53
A generic color palette of RGBA colors.
A generic color palette of hexadecimal numbers.
A 2-color palette inspired by the Playdate. Link: https://kapendev.itch.io/will-of-the-hair-wisp
A 4-color palette inspired by the Game Boy. Link: https://lospec.com/palette-list/2-bit-matrix
An 8-color palette inspired by the NES. Link: https://lospec.com/palette-list/mf-8
A 16-color palette used by the PICO-8. Link: https://lospec.com/palette-list/pico-8
Flipping orientations.
A tile with a texture atlas id, size, and position.
float x() @safe nothrow @nogc @trusted refReturns a reference to the x component of the tile position.float y() @safe nothrow @nogc @trusted refReturns a reference to the y component of the tile position.Rect textureArea(Sz colCount) @safe nothrow @nogcReturns the rectangle of the tile in the texture atlas.bool hasIntersection(Rect otherArea) @safe nothrow @nogcReturns true if the tile area intersects with the given rectangle.bool hasIntersection(Tile otherTile) @safe nothrow @nogcReturns true if the tile area intersects with another tile.Rect intersection(Rect otherArea) @safe nothrow @nogcReturns the intersection rectangle of the tile area and the given rectangle.Rect intersection(Tile otherTile) @safe nothrow @nogcReturns the intersection rectangle of the tile area and another tile.Rect merger(Rect otherArea) @safe nothrow @nogcReturns the bounding rectangle of the tile area and the given rectangle.Rect merger(Tile otherTile) @safe nothrow @nogcReturns the bounding rectangle of the tile area and another tile.void followPosition(Vec2 target, float delta) @safe nothrow @nogcMoves the tile to follow the target position at the specified speed.void followPositionWithSlowdown(Vec2 target, float delta, float slowdown) @safe nothrow @nogcMoves the tile to follow the target position with gradual slowdown.A generic tile map. N is the maximum layer row or column size.
maxLayerRowColCountMaximum layer row or column size. maxLayerCapacityMaximum layer size. extraTileCountExtra tile padding added when computing visible tile ranges.TileMapLayers layersSz rowCountSz colCountshort tileWidthshort tileHeightVec2 positionshort opIndex(Sz row, Sz col, Sz layerId = 0) @nogc @safe nothrow @trusted refReturns a reference to the tile id at the given row, column, and layer.short opIndex(IVec2 position, Sz layerId = 0) @nogc @safe nothrow refReturns a reference to the tile id at the given grid position and layer.void opIndexAssign(short rhs, Sz row, Sz col, Sz layerId = 0) @nogc @safe nothrow @trustedSets the tile id at the given row, column, and layer.void opIndexAssign(short rhs, IVec2 position, Sz layerId = 0) @nogc @safe nothrowSets the tile id at the given grid position and layer.void opIndexOpAssign(IStr op)(T rhs, Sz row, Sz col, Sz layerId = 0) @nogc @safe nothrow @trustedApplies a compound assignment operator to the tile id at the given row, column, and layer.void opIndexOpAssign(IStr op)(T rhs, IVec2 position, Sz layerId = 0) @nogc @safe nothrowApplies a compound assignment operator to the tile id at the given grid position and layer.float x() @nogc @safe nothrow @trusted refReturns a reference to the x component of the map position.float y() @nogc @safe nothrow @trusted refReturns a reference to the y component of the map position.Sz hardRowCount() @nogc @safe nothrowReturns the allocated row count of the first layer (the hard limit).Sz hardColCount() @nogc @safe nothrowReturns the allocated column count of the first layer (the hard limit).bool has(Sz row, Sz col) @nogc @safe nothrowReturns true if the given row and column are within the active map bounds.bool has(IVec2 position) @nogc @safe nothrowReturns true if the given grid position is within the active map bounds.bool hasSize() @nogc @safe nothrowReturns true if the map has a non-zero tile size and a non-zero active area.Vec2 worldPointAt(int gridX, int gridY) @nogc @safe nothrowReturns the world position of the top-left corner of the tile at the given grid coordinates.Vec2 worldPointAt(IVec2 gridPoint) @nogc @safe nothrowReturns the world position of the top-left corner of the tile at the given grid point.IVec2 gridPointAt(float worldX, float worldY) @nogc @safe nothrowReturns the grid coordinates of the tile that contains the given world position.IVec2 gridPointAt(Vec2 worldPoint) @nogc @safe nothrowReturns the grid coordinates of the tile that contains the given world point.Fault parseCsv(IStr csv, short newTileWidth, short newTileHeight, Sz layerId = 0, bool isMinZero = false, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowParses a CSV string into the specified layer, using the given tile size. Returns a fault if the CSV is empty, contains invalid values, or exceeds the hard layer bounds. If `isMinZero` is true, tile...Fault parseCsv(IStr csv, Sz layerId = 0, bool isMinZero = false, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowParses a CSV string into the specified layer using the current tile size. Returns a fault if parsing fails.Fault parseTmx(IStr tmx, IStr file = __FILE__, Sz line = __LINE__) @trusted @safe nothrowParses a TMX (Tiled XML) map file, extracting tile size and all CSV data layers. Does not support infinite maps. Returns a fault if parsing fails.void resizeHard(Sz newHardRowCount, Sz newHardColCount, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowAllocates or resizes all layers to the given hard row and column counts. Clamps to `maxLayerRowColCount`. Creates a default layer if the map is empty.void free(IStr file = __FILE__, Sz line = __LINE__) @safe nothrowFrees all layers and associated memory.void resize(Sz newRowCount, Sz newColCount) @safe nothrow @nogcSets the active row and column count without reallocating. Asserts if either value exceeds the hard limit.void resizeTileSize(short newTileWidth, short newTileHeight) @safe nothrow @nogcSets the tile size in pixels.void followPosition(Vec2 target, float delta) @safe nothrow @nogcMoves the map to follow the target position at the specified speed.void followPositionWithSlowdown(Vec2 target, float delta, float slowdown) @safe nothrow @nogcMoves the map to follow the target position with gradual slowdown.auto gridPoints(Vec2 topLeftViewPoint, Vec2 bottomRightViewPoint) @safe nothrow @nogcReturns a lazy range of grid points visible within the given view corners. Includes one extra tile of padding on the far edges via `extraTileCount`.auto gridPoints(Rect viewArea) @safe nothrow @nogcReturns a lazy range of grid points visible within the given view rectangle.A single sprite animation, defined by its position in an atlas and playback settings.
ubyte frameRowubyte frameCountubyte frameSpeedbool canRepeatA sprite animation group that picks between 2 animations based on a direction angle.
ubyte[2] frameRowsubyte frameCountubyte frameSpeedbool canRepeat angleStepThe angle step in degrees used to snap the input angle.SpriteAnimation pick(float angle) @safe nothrow @nogcPicks an animation based on the given angle in degrees.A sprite animation group that picks between 4 animations based on a direction angle.
ubyte[4] frameRowsubyte frameCountubyte frameSpeedbool canRepeat angleStepThe angle step in degrees used to snap the input angle.SpriteAnimation pick(float angle) @safe nothrow @nogcPicks an animation based on the given angle in degrees.A sprite animation group that picks between 8 animations based on a direction angle.
ubyte[8] frameRowsubyte frameCountubyte frameSpeedbool canRepeat angleStepThe angle step in degrees used to snap the input angle.SpriteAnimation pick(float angle) @safe nothrow @nogcPicks an animation based on the given angle in degrees.A sprite animation group that picks between 16 animations based on a direction angle.
ubyte[16] frameRowsubyte frameCountubyte frameSpeedbool canRepeat angleStepThe angle step in degrees used to snap the input angle.SpriteAnimation pick(float angle) @safe nothrow @nogcPicks an animation based on the given angle in degrees.A sprite with support for animation, positioning, and movement.
short widthshort heightushort atlasLeftushort atlasTopfloat frameProgressbool isPausedSpriteAnimation animationVec2 positionHook hookFlip flipfloat x() @safe nothrow @nogc @trusted refReturns a reference to the x component of the sprite position.float y() @safe nothrow @nogc @trusted refReturns a reference to the y component of the sprite position.bool hasFirstFrameProgress() @safe nothrow @nogcReturns true if the sprite is on the first animation frame progress.bool hasLastFrameProgress() @safe nothrow @nogcReturns true if the sprite is on the last animation frame progress.void play(SpriteAnimation newAnimation, bool canKeepProgress = false) @safe nothrow @nogcStarts playing a new animation, optionally preserving current frame progress.void followPosition(Vec2 target, float delta) @safe nothrow @nogcMoves the sprite to follow the target position at the specified speed.void followPositionWithSlowdown(Vec2 target, float delta, float slowdown) @safe nothrow @nogcMoves the sprite to follow the target position with gradual slowdown.this(short width, short height, ushort atlasLeft, ushort atlasTop, Vec2 position = Vec2(), Hook hook = Hook.topLeft)Initializes the sprite with the specified size, atlas position, and optional world position.How to draw a sprite stack layer.
A sprite stack.
ubyte widthubyte heightushort atlasLeftushort atlasTopSpriteStackDrawMode drawModeubyte layerCountVec2 positionfloat rotationA helper for changing the color of sprite stack layers.
Rgba makeColor(float lightingProgress) @safe nothrow @nogcReturns a new color. Value `lightingProgress` should be between 0.0 and 1.0 (inclusive).Rgba makeColor(uint layer, uint layerCount) @safe nothrow @nogcReturns a new color. The lighting progress is `layer / layerCount` for this function.Rgba makeColorIfIsActive(float lightingProgress) @safe nothrow @nogcReturns a new color. Value `lightingProgress` should be between 0.0 and 1.0 (inclusive).Rgba makeColorIfIsActive(uint layer, uint layerCount) @safe nothrow @nogcReturns a new color. The lighting progress is `layer / layerCount` for this function.A generic timer with pause/resume and repeat support. The tickTimeFunc alias must be a function that returns a float or double value. That value should be the elapsed time at the start of the current tick.
float durationfloat pauseTimefloat startTimefloat stopTimeElapsedTimeBufferbool canRepeatvoid start(float newDuration, bool newCanRepeat) @safe nothrow @nogcStarts the timer with new duration and repeat behavior.void start(float newDuration = - 1.0f) @safe nothrow @nogcStarts the timer with an optional new duration.float time() @safe nothrow @nogcReturns the current time of the timer and handles stop/repeat logic.float timeLeft() @safe nothrow @nogcReturns the remaining time of the timer and handles stop/repeat logic.void setTime(float newTime) @safe nothrow @nogcSets the current time of the timer. If the given value is non-zero, the timer becomes active.float progressLeftOrZero() @safe nothrow @nogcReturns the remaining progress (between 0.0 to 1.0), or zero if inactive.void setProgress(float value) @safe nothrow @nogcSets the progress to a specific value (between 0.0 to 1.0).void setProgressLeft(float value) @safe nothrow @nogcSets the remaining progress to a specific value (between 0.0 to 1.0).this(float duration, bool canRepeat = false)Initializes the timer with the specified duration and repeat behavior.The kind of a story line.
An operation in the story expression language.
A fixed-size word in the story expression language.
A number in the story expression language.
The underlying data of a story value.
A value in the story expression language, either a word or a number.
StoryValueData dataA named variable in the story expression language.
A start and end index pair used to identify ranges in the story.
uint auint bA story script with its associated state for parsing and execution.
LStr scriptList!StoryStartEndPair pairsList!StoryVariable labelsList!StoryVariable variablesStoryNumber lineIndexStoryNumber nextLabelIndexStoryNumber previousMenuResultStoryNumber faultPrepareIndexStoryOp faultOpSz faultTokenPositionbool debugModebool linearModeEchonFunc echonFuncT xT yA generic box ID.
Generic box flags.
An box actor ID.
A box wall ID.
A generic box ID pair.
A box actor ID pair.
A wall actor ID pair.
The side of a box.
The data of a box.
A box world.
Grid!BoxUnionIdGroup gridBoxIdBuffer collisionIdBufferBoxIdBuffer squishedIdBufferint gridTileWidthint gridTileHeightBoxWallId pushWall(Box box, BoxSide side = BoxSide.none, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowBoxActorId pushActor(Box box, BoxSide side = BoxSide.none, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowFault parseWallsCsv(IStr csv, int tileWidth, int tileHeight, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowvoid enableGrid(Sz rowCount, Sz colCount, int tileWidth, int tileHeight, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowBoxWallId moveActorXToWithSlowdown(BoxActorId id, float to, float amount, float slowdown) @safe nothrow @nogcBoxWallId moveActorYToWithSlowdown(BoxActorId id, float to, float amount, float slowdown) @safe nothrow @nogcBoxWallIdPair moveActorToWithSlowdown(BoxActorId id, Vec2 to, Vec2 amount, float slowdown) @safe nothrow @nogcBoxActorId[] moveWallXToWithSlowdown(BoxWallId id, float to, float amount, float slowdown) @safe nothrow @nogcBoxActorId[] moveWallYToWithSlowdown(BoxWallId id, float to, float amount, float slowdown) @safe nothrow @nogcBoxActorId[] moveWallToWithSlowdown(BoxWallId id, Vec2 to, Vec2 amount, float slowdown) @safe nothrow @nogcThe parts of a 9-slice.
Information about the viewport, including its drawing region and size constraints.
Functions 7
Variables 9
defaultStoryFixedListCapacity = 16HexPalette!2 wisp2A 2-color palette inspired by the Playdate. Link: https://kapendev.itch.io/will-of-the-hair-wisp
HexPalette!4 gb4A 4-color palette inspired by the Game Boy. Link: https://lospec.com/palette-list/2-bit-matrix
HexPalette!8 nes8An 8-color palette inspired by the NES. Link: https://lospec.com/palette-list/mf-8
HexPalette!16 pico8A 16-color palette used by the PICO-8. Link: https://lospec.com/palette-list/pico-8
boxNoneId = 0boxUnionTypeBit = (cast(BoxUnionId) 1) << (BoxUnionId.sizeof * 8 - 1)boxErrorMessage = "Box is invalid or was never assigned."boxFixedCapacity = 256