Data Structures | Typedefs | Enumerations
Tilengine.h File Reference

Data Structures

struct  TLN_Affine
 
struct  Tile
 
struct  TLN_SequenceFrame
 
struct  TLN_ColorStrip
 
struct  TLN_SpriteData
 
struct  TLN_SpriteInfo
 
struct  TLN_TileInfo
 
struct  TLN_PixelMap
 

Typedefs

typedef unsigned char bool
 
typedef struct Tile Tile
 
typedef struct TileTLN_Tile
 
typedef struct Tileset * TLN_Tileset
 
typedef struct Tilemap * TLN_Tilemap
 
typedef struct Palette * TLN_Palette
 
typedef struct Spriteset * TLN_Spriteset
 
typedef struct Sequence * TLN_Sequence
 
typedef struct SequencePack * TLN_SequencePack
 
typedef struct Bitmap * TLN_Bitmap
 

Enumerations

enum  TLN_TileFlags {
  FLAG_NONE = 0, FLAG_FLIPX = BITVAL(15), FLAG_FLIPY = BITVAL(14), FLAG_ROTATE = BITVAL(13),
  FLAG_PRIORITY = BITVAL(12)
}
 
enum  TLN_Blend {
  BLEND_NONE, BLEND_MIX25, BLEND_MIX50, BLEND_MIX75,
  BLEND_ADD, BLEND_SUB, BLEND_MOD, BLEND_CUSTOM
}
 
enum  TLN_Overlay {
  TLN_OVERLAY_NONE, TLN_OVERLAY_SHADOWMASK, TLN_OVERLAY_APERTURE, TLN_OVERLAY_SCANLINES,
  TLN_OVERLAY_CUSTOM
}
 
enum  TLN_Input {
  INPUT_NONE, INPUT_UP, INPUT_DOWN, INPUT_LEFT,
  INPUT_RIGHT, INPUT_A, INPUT_B, INPUT_C,
  INPUT_D
}
 
enum  TLN_WindowFlags {
  CWF_FULLSCREEN = (1<<0), CWF_VSYNC = (1<<1), CWF_S1 = (1<<2), CWF_S2 = (2<<2),
  CWF_S3 = (3<<2), CWF_S4 = (4<<2), CWF_S5 = (5<<2)
}
 
enum  TLN_Error {
  TLN_ERR_OK, TLN_ERR_OUT_OF_MEMORY, TLN_ERR_IDX_LAYER, TLN_ERR_IDX_SPRITE,
  TLN_ERR_IDX_ANIMATION, TLN_ERR_IDX_PICTURE, TLN_ERR_REF_TILESET, TLN_ERR_REF_TILEMAP,
  TLN_ERR_REF_SPRITESET, TLN_ERR_REF_PALETTE, TLN_ERR_REF_SEQUENCE, TLN_ERR_REF_SEQPACK,
  TLN_ERR_REF_BITMAP, TLN_ERR_NULL_POINTER, TLN_ERR_FILE_NOT_FOUND, TLN_ERR_WRONG_FORMAT,
  TLN_ERR_WRONG_SIZE, TLN_ERR_UNSUPPORTED
}
 

Functions

Setup

Basic setup and management

TLNAPI bool TLN_Init (int hres, int vres, int numlayers, int numsprites, int numanimations)
 Initializes the graphic engine in 32 bpp pixel format. More...
 
TLNAPI bool TLN_InitBPP (int hres, int vres, int bpp, int numlayers, int numsprites, int numanimations)
 As of version 1.12.1, this feature has been removed. Only 32 bpp is supported. The function call has been left for backwards binary compatibility but it defaults to TLN_Init() with 32 bpp.
 
TLNAPI void TLN_Deinit (void)
 Deinitialises engine and frees used resources.
 
TLNAPI int TLN_GetWidth (void)
 Returns the width in pixels of the framebuffer. More...
 
TLNAPI int TLN_GetHeight (void)
 Returns the height in pixels of the framebuffer. More...
 
TLNAPI int TLN_GetBPP (void)
 Returns the pixel format of the framebuffer. More...
 
TLNAPI uint32_t TLN_GetNumObjects (void)
 Returns the number of objets used by the engine so far. More...
 
TLNAPI uint32_t TLN_GetUsedMemory (void)
 Returns the total amount of memory used by the objects. More...
 
TLNAPI uint32_t TLN_GetVersion (void)
 Retrieves Tilengine dll version. More...
 
TLNAPI int TLN_GetNumLayers (void)
 Returns the number of layers specified during initialisation. More...
 
TLNAPI int TLN_GetNumSprites (void)
 Returns the number of sprites specified during initialisation. More...
 
TLNAPI void TLN_SetBGColor (uint8_t r, uint8_t g, uint8_t b)
 Sets the background color. More...
 
TLNAPI bool TLN_SetBGColorFromTilemap (TLN_Tilemap tilemap)
 Sets the background color from a Tilemap defined color. More...
 
TLNAPI bool TLN_SetBGBitmap (TLN_Bitmap bitmap)
 Sets a static bitmap as background. More...
 
TLNAPI bool TLN_SetBGPalette (TLN_Palette palette)
 Changes the palette for the background bitmap. More...
 
TLNAPI void TLN_SetRasterCallback (void(*callback)(int))
 Specifies the address of the funcion to call for each drawn scanline. More...
 
TLNAPI void TLN_SetRenderTarget (uint8_t *data, int pitch)
 Sets the output surface for rendering. More...
 
TLNAPI void TLN_UpdateFrame (int time)
 Draws the frame to the previously specified render target. More...
 
TLNAPI void TLN_BeginFrame (int time)
 Starts active rendering of the current frame. More...
 
TLNAPI bool TLN_DrawNextScanline (void)
 Draws the next scanline of the frame started with TLN_BeginFrame() or TLN_BeginWindowFrame() More...
 
TLNAPI void TLN_SetLoadPath (const char *path)
 Sets base path for TLN_LoadXXX functions. More...
 
TLNAPI void TLN_SetCustomBlendFunction (uint8_t(*blend_function)(uint8_t src, uint8_t dst))
 Sets custom blend function to use when BLEND_CUSTOM mode is selected. More...
 
Errors

Error handling

TLNAPI void TLN_SetLastError (TLN_Error error)
 Sets the global error code of tilengine. Useful for custom loaders that need to set the error state. More...
 
TLNAPI TLN_Error TLN_GetLastError (void)
 Returns the last error after an invalid operation. More...
 
TLNAPI const char * TLN_GetErrorString (TLN_Error error)
 Returns the string description of the specified error code. More...
 
Windowing

Built-in window and input management

TLNAPI bool TLN_CreateWindow (const char *overlay, TLN_WindowFlags flags)
 Creates a window for rendering. More...
 
TLNAPI bool TLN_CreateWindowThread (const char *overlay, TLN_WindowFlags flags)
 Creates a multithreaded window for rendering. More...
 
TLNAPI void TLN_SetWindowTitle (const char *title)
 Sets window title. More...
 
TLNAPI bool TLN_ProcessWindow (void)
 Does basic window housekeeping in signgle-threaded window. More...
 
TLNAPI bool TLN_IsWindowActive (void)
 Checks window state. More...
 
TLNAPI bool TLN_GetInput (TLN_Input id)
 Returns the state of a given input. More...
 
TLNAPI int TLN_GetLastInput (void)
 Returns the last pressed input button. More...
 
TLNAPI void TLN_DrawFrame (int time)
 Draws a frame to the window. More...
 
TLNAPI void TLN_WaitRedraw (void)
 Thread synchronization for multithreaded window. Waits until the current frame has ended rendering. More...
 
TLNAPI void TLN_DeleteWindow (void)
 Deletes the window previoulsy created with TLN_CreateWindow() or TLN_CreateWindowThread() More...
 
TLNAPI void TLN_EnableBlur (bool mode)
 Enables or disables a simple horizontal blur effect to emulate noisy composite video. More...
 
TLNAPI void TLN_EnableCRTEffect (TLN_Overlay overlay, uint8_t overlay_factor, uint8_t threshold, uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, bool blur, uint8_t glow_factor)
 Enables CRT simulation post-processing effect to give true retro appeareance. More...
 
TLNAPI void TLN_DisableCRTEffect (void)
 Disables the CRT post-processing effect. More...
 
TLNAPI void TLN_Delay (uint32_t msecs)
 Suspends execition for a fixed time. More...
 
TLNAPI uint32_t TLN_GetTicks (void)
 Returns the number of milliseconds since application start.
 
TLNAPI void TLN_BeginWindowFrame (int time)
 Begins active rendering frame in built-in window. More...
 
TLNAPI void TLN_EndWindowFrame (void)
 Finishes rendering the current frame and updates the built-in window. More...
 
Spritesets

Spriteset resources management for sprites

TLNAPI TLN_Spriteset TLN_CreateSpriteset (TLN_Bitmap bitmap, TLN_SpriteData *data, int num_entries)
 Creates a new spriteset. More...
 
TLNAPI TLN_Spriteset TLN_LoadSpriteset (const char *name)
 Loads a spriteset from a png/txt file pair. More...
 
TLNAPI TLN_Spriteset TLN_CloneSpriteset (TLN_Spriteset src)
 Creates a duplicate of the specified spriteset and its associated palette. More...
 
TLNAPI bool TLN_GetSpriteInfo (TLN_Spriteset spriteset, int entry, TLN_SpriteInfo *info)
 Query the details about the specified sprite inside a spriteset. More...
 
TLNAPI TLN_Palette TLN_GetSpritesetPalette (TLN_Spriteset spriteset)
 Returns a reference to the palette associated to the specified spriteset. More...
 
TLNAPI int TLN_FindSpritesetSprite (TLN_Spriteset spriteset, char *name)
 Returns a reference to the palette associated to the specified spriteset. More...
 
TLNAPI bool TLN_DeleteSpriteset (TLN_Spriteset Spriteset)
 Deletes the specified spriteset and frees memory. More...
 
Tilesets

Tileset resources management for background layers

TLNAPI TLN_Tileset TLN_CreateTileset (int numtiles, int width, int height, TLN_Palette palette, TLN_SequencePack sp, uint8_t *types)
 Creates a new tileset. More...
 
TLNAPI TLN_Tileset TLN_LoadTileset (const char *filename)
 Loads a tileset from a Tiled .tsx file. More...
 
TLNAPI TLN_Tileset TLN_CloneTileset (TLN_Tileset src)
 Creates a duplicate of the specified tileset and its associated palette. More...
 
TLNAPI bool TLN_SetTilesetPixels (TLN_Tileset tileset, int entry, uint8_t *srcdata, int srcpitch)
 Sets pixel data for a tile in a tileset. More...
 
TLNAPI bool TLN_CopyTile (TLN_Tileset tileset, int src, int dst)
 Copies tile graphic data inside a Tileset specified tileset. More...
 
TLNAPI int TLN_GetTileWidth (TLN_Tileset tileset)
 Returns the width in pixels of each individual tile in the tileset. More...
 
TLNAPI int TLN_GetTileHeight (TLN_Tileset tileset)
 Returns the height in pixels of each individual tile in the tileset. More...
 
TLNAPI TLN_Palette TLN_GetTilesetPalette (TLN_Tileset tileset)
 Returns a reference to the palette associated to the specified tileset. More...
 
TLNAPI TLN_SequencePack TLN_GetTilesetSequencePack (TLN_Tileset tileset)
 Returns a reference to the optional sequence pack associated to the specified tileset. More...
 
TLNAPI bool TLN_DeleteTileset (TLN_Tileset tileset)
 Deletes the specified tileset and frees memory. More...
 
Tilemaps

Tilemap resources management for background layers

TLNAPI TLN_Tilemap TLN_CreateTilemap (int rows, int cols, TLN_Tile tiles, uint32_t bgcolor, TLN_Tileset tileset)
 Creates a new tilemap. More...
 
TLNAPI TLN_Tilemap TLN_LoadTilemap (const char *filename, const char *layername)
 Loads a tilemap layer from a Tiled .tmx file. More...
 
TLNAPI TLN_Tilemap TLN_CloneTilemap (TLN_Tilemap src)
 Creates a duplicate of the specified tilemap. More...
 
TLNAPI int TLN_GetTilemapRows (TLN_Tilemap tilemap)
 Returns the number of vertical tiles in the tilemap. More...
 
TLNAPI int TLN_GetTilemapCols (TLN_Tilemap tilemap)
 Returns the number of horizontal tiles in the tilemap. More...
 
TLNAPI TLN_Tileset TLN_GetTilemapTileset (TLN_Tilemap tilemap)
 Returns the optional associated tileset to the specified tilemap. More...
 
TLNAPI bool TLN_GetTilemapTile (TLN_Tilemap tilemap, int row, int col, TLN_Tile tile)
 Gets data of a single tile inside a tilemap. More...
 
TLNAPI bool TLN_SetTilemapTile (TLN_Tilemap tilemap, int row, int col, TLN_Tile tile)
 Sets a tile of a tilemap. More...
 
TLNAPI bool TLN_CopyTiles (TLN_Tilemap src, int srcrow, int srccol, int rows, int cols, TLN_Tilemap dst, int dstrow, int dstcol)
 Copies blocks of tiles between two tilemaps. More...
 
TLNAPI bool TLN_DeleteTilemap (TLN_Tilemap tilemap)
 Deletes the specified tilemap and frees memory. More...
 
Palettes

Color palette resources management for sprites and background layers

TLNAPI TLN_Palette TLN_CreatePalette (int entries)
 Creates a new color table. More...
 
TLNAPI TLN_Palette TLN_LoadPalette (const char *filename)
 Loads a palette from a standard .act file. More...
 
TLNAPI TLN_Palette TLN_ClonePalette (TLN_Palette src)
 Creates a duplicate of the specified palette. More...
 
TLNAPI bool TLN_SetPaletteColor (TLN_Palette palette, int color, uint8_t r, uint8_t g, uint8_t b)
 Sets the RGB color value of a palette entry. More...
 
TLNAPI bool TLN_MixPalettes (TLN_Palette src1, TLN_Palette src2, TLN_Palette dst, uint8_t factor)
 Mixes two palettes to create a third one. More...
 
TLNAPI bool TLN_AddPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by adding the provided color value to the selected range. The result is always a brighter color. More...
 
TLNAPI bool TLN_SubPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by subtracting the provided color value to the selected range. The result is always a darker color. More...
 
TLNAPI bool TLN_ModPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by modulating (normalized product) the provided color value to the selected range. The result is always a darker color. More...
 
TLNAPI uint8_t * TLN_GetPaletteData (TLN_Palette palette, int index)
 Returns the color value of a palette entry. More...
 
TLNAPI bool TLN_DeletePalette (TLN_Palette palette)
 Deletes the specified palette and frees memory. More...
 
Bitmaps

Bitmap management

TLNAPI TLN_Bitmap TLN_CreateBitmap (int width, int height, int bpp)
 Creates a memory bitmap. More...
 
TLNAPI TLN_Bitmap TLN_LoadBitmap (const char *filename)
 Load image file (8-bit BMP or PNG) More...
 
TLNAPI TLN_Bitmap TLN_CloneBitmap (TLN_Bitmap src)
 Creates a copy of a bitmap. More...
 
TLNAPI uint8_t * TLN_GetBitmapPtr (TLN_Bitmap bitmap, int x, int y)
 Gets memory access for direct pixel manipulation. More...
 
TLNAPI int TLN_GetBitmapWidth (TLN_Bitmap bitmap)
 Returns the width in pixels. More...
 
TLNAPI int TLN_GetBitmapHeight (TLN_Bitmap bitmap)
 Returns the height in pixels. More...
 
TLNAPI int TLN_GetBitmapDepth (TLN_Bitmap bitmap)
 Returns the bits per pixel. More...
 
TLNAPI int TLN_GetBitmapPitch (TLN_Bitmap bitmap)
 Returns the number of bytes per scaline (also known a stride) More...
 
TLNAPI TLN_Palette TLN_GetBitmapPalette (TLN_Bitmap bitmap)
 Gets the associated palete of a bitmap. More...
 
TLNAPI bool TLN_SetBitmapPalette (TLN_Bitmap bitmap, TLN_Palette palette)
 Assigns a new palette to the bitmap. More...
 
TLNAPI bool TLN_DeleteBitmap (TLN_Bitmap bitmap)
 Deletes bitmap and frees resources. More...
 
Layers

Background layers management

TLNAPI bool TLN_SetLayer (int nlayer, TLN_Tileset tileset, TLN_Tilemap tilemap)
 Configures a background layer with the specified tileset and tilemap. More...
 
TLNAPI bool TLN_SetLayerPalette (int nlayer, TLN_Palette palette)
 Sets the color palette to the layer. More...
 
TLNAPI bool TLN_SetLayerPosition (int nlayer, int hstart, int vstart)
 Sets the position of the tileset that corresponds to the upper left corner. More...
 
TLNAPI bool TLN_SetLayerScaling (int nlayer, float xfactor, float yfactor)
 Sets simple scaling. More...
 
TLNAPI bool TLN_SetLayerAffineTransform (int nlayer, TLN_Affine *affine)
 Sets affine transform matrix to enable rotating and scaling of this layer. More...
 
TLNAPI bool TLN_SetLayerTransform (int layer, float angle, float dx, float dy, float sx, float sy)
 Sets affine transform matrix to enable rotating and scaling of this layer. More...
 
TLNAPI bool TLN_SetLayerPixelMapping (int nlayer, TLN_PixelMap *table)
 Sets the table for pixel mapping render mode. More...
 
TLNAPI bool TLN_SetLayerBlendMode (int nlayer, TLN_Blend mode, uint8_t factor)
 Sets the blending mode (transparency effect) More...
 
TLNAPI bool TLN_SetLayerColumnOffset (int nlayer, int *offset)
 Enables column offset mode for this layer. More...
 
TLNAPI bool TLN_SetLayerClip (int nlayer, int x1, int y1, int x2, int y2)
 Enables clipping rectangle on selected layer. More...
 
TLNAPI bool TLN_DisableLayerClip (int nlayer)
 Disables clipping rectangle on selected layer. More...
 
TLNAPI bool TLN_SetLayerMosaic (int nlayer, int width, int height)
 Enables mosaic effect (pixelation) for selected layer. More...
 
TLNAPI bool TLN_DisableLayerMosaic (int nlayer)
 Disables mosaic effect for selected layer. More...
 
TLNAPI bool TLN_ResetLayerMode (int nlayer)
 Disables scaling or affine transform for the layer. More...
 
TLNAPI bool TLN_DisableLayer (int nlayer)
 Disables the specified layer so it is not drawn. More...
 
TLNAPI TLN_Palette TLN_GetLayerPalette (int nlayer)
 Gets the attached palette of a layer. More...
 
TLNAPI bool TLN_GetLayerTile (int nlayer, int x, int y, TLN_TileInfo *info)
 Gets info about the tile located in tilemap space. More...
 
TLNAPI int TLN_GetLayerWidth (int nlayer)
 Returns the layer width in pixels. More...
 
TLNAPI int TLN_GetLayerHeight (int nlayer)
 Returns the layer height in pixels. More...
 
Sprites

Sprites management

TLNAPI bool TLN_ConfigSprite (int nsprite, TLN_Spriteset spriteset, TLN_TileFlags flags)
 Configures a sprite, setting setting spriteset and flags at once. More...
 
TLNAPI bool TLN_SetSpriteSet (int nsprite, TLN_Spriteset spriteset)
 Assigns the spriteset and its palette to a given sprite. More...
 
TLNAPI bool TLN_SetSpriteFlags (int nsprite, TLN_TileFlags flags)
 Sets flags for a given sprite. More...
 
TLNAPI bool TLN_SetSpritePosition (int nsprite, int x, int y)
 Sets the sprite position inside the viewport. More...
 
TLNAPI bool TLN_SetSpritePicture (int nsprite, int entry)
 Sets the actual graphic to the sprite. More...
 
TLNAPI bool TLN_SetSpritePalette (int nsprite, TLN_Palette palette)
 Assigns a palette to a sprite. More...
 
TLNAPI bool TLN_SetSpriteBlendMode (int nsprite, TLN_Blend mode, uint8_t factor)
 Sets the blending mode (transparency effect) More...
 
TLNAPI bool TLN_SetSpriteScaling (int nsprite, float sx, float sy)
 Sets the scaling factor of the sprite. More...
 
TLNAPI bool TLN_ResetSpriteScaling (int nsprite)
 Disables scaling for a given sprite. More...
 
TLNAPI int TLN_GetSpritePicture (int nsprite)
 Returns the index of the assigned picture from the spriteset. More...
 
TLNAPI int TLN_GetAvailableSprite (void)
 Finds an available (unused) sprite. More...
 
TLNAPI bool TLN_EnableSpriteCollision (int nsprite, bool enable)
 Enable sprite collision checking at pixel level. More...
 
TLNAPI bool TLN_GetSpriteCollision (int nsprite)
 Gets the collision status of a given sprite. More...
 
TLNAPI bool TLN_DisableSprite (int nsprite)
 Disables the sprite so it is not drawn. More...
 
TLNAPI TLN_Palette TLN_GetSpritePalette (int nsprite)
 Gets the palette assigned to a given sprite. More...
 
Sequences

Sequence resources management for layer, sprite and palette animations

TLNAPI TLN_Sequence TLN_CreateSequence (const char *name, int target, int num_frames, TLN_SequenceFrame *frames)
 Creates a new sequence for the animation engine. More...
 
TLNAPI TLN_Sequence TLN_CreateCycle (const char *name, int num_strips, TLN_ColorStrip *strips)
 Creates a color cycle sequence for palette animation. More...
 
TLNAPI TLN_Sequence TLN_CloneSequence (TLN_Sequence src)
 Creates a duplicate of the specified sequence. More...
 
TLNAPI bool TLN_DeleteSequence (TLN_Sequence sequence)
 Deletes the sequence and frees resources. More...
 
Sequence packs

Sequence pack manager for grouping and finding sequences

TLNAPI TLN_SequencePack TLN_CreateSequencePack (void)
 Creates a new collection of sequences. More...
 
TLNAPI TLN_SequencePack TLN_LoadSequencePack (const char *filename)
 Loads a sqx file containing one or more sequences. More...
 
TLNAPI TLN_SequencePack TLN_CloneSequencePack (TLN_SequencePack src)
 
TLNAPI TLN_Sequence TLN_GetSequence (TLN_SequencePack sp, int index)
 Returns the nth sequence inside a sequence pack. More...
 
TLNAPI TLN_Sequence TLN_FindSequence (TLN_SequencePack sp, const char *name)
 Finds a sequence inside a sequence pack. More...
 
TLNAPI int TLN_GetSequencePackCount (TLN_SequencePack sp)
 Returns the number of sequences inside a sequence pack. More...
 
TLNAPI bool TLN_AddSequenceToPack (TLN_SequencePack sp, TLN_Sequence sequence)
 Adds a sequence to a sequence pack. More...
 
TLNAPI bool TLN_DeleteSequencePack (TLN_SequencePack sp)
 Deletes the specified sequence pack and frees memory. More...
 
Animations

Animation engine manager

TLNAPI bool TLN_SetPaletteAnimation (int index, TLN_Palette palette, TLN_Sequence sequence, bool blend)
 Starts a palette animation. More...
 
TLNAPI bool TLN_SetPaletteAnimationSource (int index, TLN_Palette)
 Sets the source palette of a color cycle animation. More...
 
TLNAPI bool TLN_SetTilesetAnimation (int index, int nlayer, TLN_Sequence)
 Starts a tileset animation. More...
 
TLNAPI bool TLN_SetTilemapAnimation (int index, int nlayer, TLN_Sequence)
 Starts a tilemap animation. More...
 
TLNAPI bool TLN_SetSpriteAnimation (int index, int nsprite, TLN_Sequence sequence, int loop)
 Starts a sprite animation. More...
 
TLNAPI bool TLN_GetAnimationState (int index)
 Checks the state of the specified animation. More...
 
TLNAPI bool TLN_SetAnimationDelay (int index, int delay)
 Sets the playback speed of a given animation. More...
 
TLNAPI int TLN_GetAvailableAnimation (void)
 Finds an available (unused) animation. More...
 
TLNAPI bool TLN_DisableAnimation (int index)
 Disables the animation so it stops playing and returns it to the list of available animations. More...
 

Detailed Description

Tilengine header

Author
Marc Palacios (Megamarc)
Date
Jun 2015 http://www.tilengine.org

Main header for Tilengine 2D scanline-based graphics engine

Typedef Documentation

typedef unsigned char bool

C++ bool type for C language

typedef struct Tile Tile

Tile item for Tilemap access methods

typedef struct Tile* TLN_Tile

Tile reference

typedef struct Tileset* TLN_Tileset

Opaque tileset reference

typedef struct Tilemap* TLN_Tilemap

Opaque tilemap reference

typedef struct Palette* TLN_Palette

Opaque palette reference

typedef struct Spriteset* TLN_Spriteset

Opaque sspriteset reference

typedef struct Sequence* TLN_Sequence

Opaque sequence reference

typedef struct SequencePack* TLN_SequencePack

Opaque sequence pack reference

typedef struct Bitmap* TLN_Bitmap

Opaque bitmap reference

Enumeration Type Documentation

tile/sprite flags. Can be none or a combination of the following:

Enumerator
FLAG_NONE 

no flags

FLAG_FLIPX 

horizontal flip

FLAG_FLIPY 

vertical flip

FLAG_ROTATE 

row/column flip (unsupported, Tiled compatibility)

FLAG_PRIORITY 

tile goes in front of sprite layer

enum TLN_Blend

layer blend modes. Must be one of these and are mutually exclusive:

Enumerator
BLEND_NONE 

blending disabled

BLEND_MIX25 

color averaging 1

BLEND_MIX50 

color averaging 2

BLEND_MIX75 

color averaging 3

BLEND_ADD 

color is always brighter (simulate light effects)

BLEND_SUB 

color is always darker (simulate shadow effects)

BLEND_MOD 

color is always darker (simulate shadow effects)

BLEND_CUSTOM 

user provided blend function with TLN_SetCustomBlendFunction()

overlays for CRT effect

Enumerator
TLN_OVERLAY_NONE 

no overlay

TLN_OVERLAY_SHADOWMASK 

Shadow mask pattern

TLN_OVERLAY_APERTURE 

Aperture grille pattern

TLN_OVERLAY_SCANLINES 

Scanlines pattern

TLN_OVERLAY_CUSTOM 

User-provided when calling TLN_CreateWindow()

enum TLN_Input

Standard inputs query for TLN_GetInput()

Enumerator
INPUT_NONE 

no input

INPUT_UP 

up direction

INPUT_DOWN 

down direction

INPUT_LEFT 

left direction

INPUT_RIGHT 

right direction

INPUT_A 

first action button

INPUT_B 

second action button

INPUT_C 

third action button

INPUT_D 

fourth action button

CreateWindow flags. Can be none or a combination of the following:

Enumerator
CWF_FULLSCREEN 

create a fullscreen window

CWF_VSYNC 

sync frame updates with vertical retrace

CWF_S1 

create a window the same size as the framebuffer

CWF_S2 

create a window 2x the size the framebuffer

CWF_S3 

create a window 3x the size the framebuffer

CWF_S4 

create a window 4x the size the framebuffer

CWF_S5 

create a window 5x the size the framebuffer

enum TLN_Error

Error codes

Enumerator
TLN_ERR_OK 

No error

TLN_ERR_OUT_OF_MEMORY 

Not enough memory

TLN_ERR_IDX_LAYER 

Layer index out of range

TLN_ERR_IDX_SPRITE 

Sprite index out of range

TLN_ERR_IDX_ANIMATION 

Animation index out of range

TLN_ERR_IDX_PICTURE 

Picture or tile index out of range

TLN_ERR_REF_TILESET 

Invalid TLN_Tileset reference

TLN_ERR_REF_TILEMAP 

Invalid TLN_Tilemap reference

TLN_ERR_REF_SPRITESET 

Invalid TLN_Spriteset reference

TLN_ERR_REF_PALETTE 

Invalid TLN_Palette reference

TLN_ERR_REF_SEQUENCE 

Invalid TLN_Sequence reference

TLN_ERR_REF_SEQPACK 

Invalid TLN_SequencePack reference

TLN_ERR_REF_BITMAP 

Invalid TLN_Bitmap reference

TLN_ERR_NULL_POINTER 

Null pointer as argument

TLN_ERR_FILE_NOT_FOUND 

Resource file not found

TLN_ERR_WRONG_FORMAT 

Resource file has invalid format

TLN_ERR_WRONG_SIZE 

A width or height parameter is invalid

TLN_ERR_UNSUPPORTED 

Unsupported function

Function Documentation

TLNAPI bool TLN_Init ( int  hres,
int  vres,
int  numlayers,
int  numsprites,
int  numanimations 
)

Initializes the graphic engine in 32 bpp pixel format.

Parameters
hreshorizontal resolution in pixels
vresvertical resolution in pixels
numlayersnumber of layers
numspritesnumber of sprites
numanimationsnumber of animations

Performs initialisation of the main engine, creates the viewport with the specified dimensions and allocates the number of layers, sprites and animation slots

TLNAPI int TLN_GetWidth ( void  )

Returns the width in pixels of the framebuffer.

See also
TLN_Init(), TLN_GetHeight()
TLNAPI int TLN_GetHeight ( void  )

Returns the height in pixels of the framebuffer.

See also
TLN_Init(), TLN_GetWidth()
TLNAPI int TLN_GetBPP ( void  )

Returns the pixel format of the framebuffer.

See also
TLN_InitBPP()
TLNAPI uint32_t TLN_GetNumObjects ( void  )

Returns the number of objets used by the engine so far.

Remarks
The objects is the total amount of tilesets, tilemaps, spritesets, palettes or sequences combined
See also
TLN_GetUsedMemory()
TLNAPI uint32_t TLN_GetUsedMemory ( void  )

Returns the total amount of memory used by the objects.

See also
TLN_GetNumObjects()
TLNAPI uint32_t TLN_GetVersion ( void  )

Retrieves Tilengine dll version.

Returns
Returns a 32-bit integer containing three packed numbers: bits 23:16 -> major version bits 15: 8 -> minor version bits 7: 0 -> bugfix revision
Remarks
Compare this number with the TILENGINE_HEADER_VERSION macro to check that both versions match!
TLNAPI int TLN_GetNumLayers ( void  )

Returns the number of layers specified during initialisation.

See also
TLN_Init()
TLNAPI int TLN_GetNumSprites ( void  )

Returns the number of sprites specified during initialisation.

See also
TLN_Init()
TLNAPI void TLN_SetBGColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the background color.

Parameters
rred component (0-255)
ggreen component (0-255)
bblue component (0-255)

The background color is the color of the pixel when there isn't any layer or sprite at that position.

Remarks
This funcion can be called during a raster callback to create gradient backgrounds
TLNAPI bool TLN_SetBGColorFromTilemap ( TLN_Tilemap  tilemap)

Sets the background color from a Tilemap defined color.

Parameters
tilemapReference to the tilemap with the background color to set
TLNAPI bool TLN_SetBGBitmap ( TLN_Bitmap  bitmap)

Sets a static bitmap as background.

Parameters
bitmapReference to bitmap for the background. Set NULL to disable

Sets an optional bitmap instead of a solid color where there is no layer or sprite. Unlike tilemaps or sprites, this bitmap cannot be moved and has no transparency

See also
TLN_SetBGPalette()
TLNAPI bool TLN_SetBGPalette ( TLN_Palette  palette)

Changes the palette for the background bitmap.

Parameters
paletteReference to palette
See also
TLN_SetBGBitmap()
TLNAPI void TLN_SetRasterCallback ( void(*)(int)  callback)

Specifies the address of the funcion to call for each drawn scanline.

Parameters
callbackAddress of the function to call

Tilengine renders its output line by line, just as the 2D graphics chips did. The raster callback is a way to simulate the "horizontal blanking interrupt" of those systems, where many parameters of the rendering can be modified per line.

Remarks
Setting a raster callback is optional, but much of the fun of using Tilengine comes from the use of raster effects
TLNAPI void TLN_SetRenderTarget ( uint8_t *  data,
int  pitch 
)

Sets the output surface for rendering.

Parameters
dataPointer to the start of the target framebuffer
pitchNumber of bytes per each scanline of the framebuffer

Sets the output surface for rendering. Tilengine doesn't provide a windowing or hardware video access. The application is responsible of allocating and maintaining the surface where tilengine does the rendering. It can be a SDL surface, a locked DirectX surface, an OpenGL texture, or whatever the application has access to.

Remarks
The render target pixel format must be 32 bits RGBA
See also
TLN_UpdateFrame()
TLNAPI void TLN_UpdateFrame ( int  time)

Draws the frame to the previously specified render target.

Parameters
timetimestamp for animation control
Remarks
the timestamp value meaning is application defined, but its units must match the same used in the sequences xml file. It usually is the frame number or millisecond count
See also
TLN_SetRenderTarget()
TLNAPI void TLN_BeginFrame ( int  time)

Starts active rendering of the current frame.

Parameters
timeTimestamp value
See also
TLN_DrawNextScanline(), TLN_BeginWindowFrame(), TLN_EndWindowFrame()
TLNAPI bool TLN_DrawNextScanline ( void  )

Draws the next scanline of the frame started with TLN_BeginFrame() or TLN_BeginWindowFrame()

Remarks
Use this function in conjunction with TLN_BeginFrame() (custom render target) or TLN_BeginWindoFrame() and TLN_EndWindowFrame() (built-in window) for active rendering without callbacks.
Returns
true if there are still scanlines to draw or false when the frame is complete
TLNAPI void TLN_SetLoadPath ( const char *  path)

Sets base path for TLN_LoadXXX functions.

Parameters
pathBase path. Files will load at path/filename. Can be NULL
TLNAPI void TLN_SetCustomBlendFunction ( uint8_t(*)(uint8_t src, uint8_t dst)  blend_function)

Sets custom blend function to use when BLEND_CUSTOM mode is selected.

Parameters
blend_functionpointer to a user-provided function that takes two parameters: source component intensity, destination component intensity, and returns the desired intensity. This function is called for each RGB component when blending is enabled
Remarks
This function is not called in realtime, but its result is precomputed into a look-up table when TLN_SetCustomBlendFunction() is called, so the performance impact is minimal, just as low as the other built-in blending modes
See also
TLN_SetSpriteBlendMode()|TLN_SetLayerBlendMode()
TLNAPI void TLN_SetLastError ( TLN_Error  error)

Sets the global error code of tilengine. Useful for custom loaders that need to set the error state.

Parameters
errorError code to set
See also
TLN_GetLastError()
TLNAPI TLN_Error TLN_GetLastError ( void  )

Returns the last error after an invalid operation.

See also
TLN_Error
TLNAPI const char* TLN_GetErrorString ( TLN_Error  error)

Returns the string description of the specified error code.

Parameters
errorError code to get description
See also
TLN_GetLastError()
TLNAPI bool TLN_CreateWindow ( const char *  overlay,
TLN_WindowFlags  flags 
)

Creates a window for rendering.

Parameters
overlayOptional path of a bmp file to overlay (for emulating RGB mask, scanlines, etc)
flagsMask of the possible creation flags: CWF_FULLSCREEN, CWF_VSYNC, CWF_S1 - CWF_S5 (scaling factor, none = auto max)
Returns
True if window was created or false if error

Creates a host window with basic user input for tilengine. If fullscreen, it uses the desktop resolution and stretches the output resolution with aspect correction, letterboxing or pillarboxing as needed. If windowed, it creates a centered window that is the maximum possible integer multiply of the resolution configured at TLN_Init()

Remarks
Using this feature is optional, Tilengine is designed to output its rendering to a user-provided surface so it can be used as a backend renderer of an already existing framework. But it is provided for convenience, so it isn't needed to provide external components to run the examples or do engine tests.
See also
TLN_DeleteWindow(), TLN_ProcessWindow(), TLN_GetInput(), TLN_DrawFrame()
TLNAPI bool TLN_CreateWindowThread ( const char *  overlay,
TLN_WindowFlags  flags 
)

Creates a multithreaded window for rendering.

Parameters
overlayOptional path of a bmp file to overlay (for emulating RGB mask, scanlines, etc)
flagsMask of the possible creation flags: CWF_FULLSCREEN, CWF_VSYNC, CWF_S1 - CWF_S5 (scaling factor, none = auto max)
Returns
True if window was created or false if error

Creates a host window with basic user input for tilengine. If fullscreen, it uses the desktop resolution and stretches the output resolution with aspect correction, letterboxing or pillarboxing as needed. If windowed, it creates a centered window that is the maximum possible integer multiply of the resolution configured at TLN_Init()

Remarks
Unlike TLN_CreateWindow, This window runs in its own thread
See also
TLN_DeleteWindow(), TLN_IsWindowActive(), TLN_GetInput(), TLN_UpdateFrame()
TLNAPI void TLN_SetWindowTitle ( const char *  title)

Sets window title.

Parameters
titleText with the title to set
TLNAPI bool TLN_ProcessWindow ( void  )

Does basic window housekeeping in signgle-threaded window.

Returns
True if window is active or false if the user has requested to end the application (by pressing Esc key or clicking the close button)

If a window has been created with TLN_CreateWindow, this function must be called periodically (call it inside the main loop so it gets called regularly). If the window was created with TLN_CreateWindowThread, do not use it

See also
TLN_CreateWindow()
TLNAPI bool TLN_IsWindowActive ( void  )

Checks window state.

Returns
True if window is active or false if the user has requested to end the application (by pressing Esc key or clicking the close button)
See also
TLN_CreateWindow(), TLN_CreateWindowThread()
TLNAPI bool TLN_GetInput ( TLN_Input  input)

Returns the state of a given input.

Parameters
inputInput to check state. It can be one of the following values:
  • INPUT_UP
  • INPUT_DOWN
  • INPUT_LEFT
  • INPUT_RIGHT
  • INPUT_A
  • INPUT_B
  • INPUT_C
  • INPUT_D
Returns
True if that input is pressed or false if not

If a window has been created with TLN_CreateWindow, it provides basic user input. It simulates a classic arcade setup, with four directional buttons (INPUT_UP to INPUT_RIGHT) and four action buttons (INPUT_A to INPUT_D). Directional buttons are mapped to keyboard cursors or joystick D-PAD, and the four action buttons are the keys Z,X,C,V or joystick buttons 1 to 4.

See also
TLN_CreateWindow()
TLNAPI int TLN_GetLastInput ( void  )

Returns the last pressed input button.

See also
TLN_GetInput()
TLNAPI void TLN_DrawFrame ( int  time)

Draws a frame to the window.

Parameters
timeTimestamp (same value as in TLN_UpdateFrame())

Draws a frame to the window

Remarks
If a window has been created with TLN_CreateWindow(), it renders the frame to it. This function is a wrapper to TLN_UpdateFrame which also automatically sets the render target for the window, so when calling this function it is not needed to call TLN_UpdateFrame() too.
See also
TLN_CreateWindow(), TLN_UpdateFrame()
TLNAPI void TLN_WaitRedraw ( void  )

Thread synchronization for multithreaded window. Waits until the current frame has ended rendering.

See also
TLN_CreateWindowThread()
TLNAPI void TLN_DeleteWindow ( void  )

Deletes the window previoulsy created with TLN_CreateWindow() or TLN_CreateWindowThread()

See also
TLN_CreateWindow()
TLNAPI void TLN_EnableBlur ( bool  mode)

Enables or disables a simple horizontal blur effect to emulate noisy composite video.

Parameters
modeEnable or disable effect
Remarks
As of release 1.12, this function has been deprecated and doesn't have effect anymore. It has been left only for ABI compatibility. Use the new TLN_EnableCRTEffect instead.
See also
TLN_EnableCRTEffect()
TLNAPI void TLN_EnableCRTEffect ( TLN_Overlay  overlay,
uint8_t  overlay_factor,
uint8_t  threshold,
uint8_t  v0,
uint8_t  v1,
uint8_t  v2,
uint8_t  v3,
bool  blur,
uint8_t  glow_factor 
)

Enables CRT simulation post-processing effect to give true retro appeareance.

Parameters
overlayOne of the enumerated TLN_Overlay types. Choosing TLN_OVERLAY_CUSTOM selects the image passed when calling TLN_CreateWindow
overlay_factorBlend factor for overlay image. 0 is full transparent (no effect), 255 is full blending
thresholdMiddle point of the brightness mapping function
v0output brightness for input brightness = 0
v1output brightness for input brightness = threshold
v2output brightness for input brightness = threshold
v3output brightness for input brightness = 255
bluradds gaussian blur to brightness overlay, softens image
glow_factorblend addition factor for brightness overlay. 0 is not addition, 255 is full addition

This function combines various effects to simulate the output of a CRT monitor with low CPU/GPU usage. A small horizontal blur is added to the frame, simulating the continuous output of a RF modulator where adjacent pixels got mixed. Many graphic designers use this feature where alternating vertical lines are used to create the illusion of more colors or blending. An secondary image is created with overbright pixels. In a real CRT, brighter colors bleed into surrounding area: the pixel size depends somewhat on its brightness. The threshold and v0 to v3 parametes define a two-segment linear mapping between source and destination brightness for the overlay. Optionally the overlay can be softened more using a slight gaussian blur filter te create a kind of "bloom" effect, and finally it is added on top of the frame with the glow_factor value.

See also
TLN_CreateWindow(),TLN_DisableCRTEffect()
TLNAPI void TLN_DisableCRTEffect ( void  )

Disables the CRT post-processing effect.

See also
TLN_EnableCRTEffect()
TLNAPI void TLN_Delay ( uint32_t  time)

Suspends execition for a fixed time.

Parameters
timeNumber of milliseconds to wait
TLNAPI void TLN_BeginWindowFrame ( int  time)

Begins active rendering frame in built-in window.

Parameters
timeTimestamp (same value as in TLN_UpdateFrame())
Remarks
Use this function instead of TLN_BeginFrame() when using the built-in window
See also
TLN_CreateWindow(), TLN_EndWindowFrame(), TLN_DrawNextScanline()
TLNAPI void TLN_EndWindowFrame ( void  )

Finishes rendering the current frame and updates the built-in window.

See also
TLN_CreateWindow(), TLN_BeginWindowFrame(), TLN_DrawNextScanline()
TLNAPI TLN_Spriteset TLN_CreateSpriteset ( TLN_Bitmap  bitmap,
TLN_SpriteData data,
int  num_entries 
)

Creates a new spriteset.

Parameters
bitmapBitmap containing the sprite graphics
dataArray of TLN_SpriteData structures with sprite descriptions
num_entriesNumber of entries in data[] array
Returns
Reference to the created spriteset, or NULL if error
See also
TLN_DeleteSpriteset()
TLNAPI TLN_Spriteset TLN_LoadSpriteset ( const char *  name)

Loads a spriteset from a png/txt file pair.

Parameters
nameBase name of the files containing the spriteset
Returns
Reference to the newly loaded spriteset or NULL if error
Remarks
The spriteset comes in a pair of files called name.png and name.txt. The png file contains the spriteset, whereas the txt contains the coordinates of the rectangles that define individual sprites. These files can be created wit the spritesheet packer tool (http://spritesheetpacker.codeplex.com/)
An associated palette is also created, it can be obtained calling TLN_GetSpritesetPalette()
TLNAPI TLN_Spriteset TLN_CloneSpriteset ( TLN_Spriteset  src)

Creates a duplicate of the specified spriteset and its associated palette.

Parameters
srcSpriteset to clone
Returns
A reference to the newly cloned spriteset, or NULL if error
See also
TLN_LoadSpriteset()
TLNAPI bool TLN_GetSpriteInfo ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteInfo info 
)

Query the details about the specified sprite inside a spriteset.

Parameters
spritesetReference to the spriteset to get info about
entryThe entry index inside the spriteset [0, num_sprites - 1]
infoPointer to application-allocated TLN_SpriteInfo structure that will receive the data
Returns
true if success or false if error
TLNAPI TLN_Palette TLN_GetSpritesetPalette ( TLN_Spriteset  spriteset)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset to obtain the palette
Remarks
The palette of a spriteset is created at load time and cannot be modified. When TLN_ConfigSprite function is used to setup a sprite, the palette associated with the specified spriteset is automatically assigned to that sprite, but it can be later replaced with TLN_SetSpritePalette
See also
TLN_SetSpritePalette()
TLNAPI int TLN_FindSpritesetSprite ( TLN_Spriteset  spriteset,
char *  name 
)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset where to find the sprite
nameName of the sprite to findo
Returns
sprite index (0 -> num_sprites - 1) if found, or -1 if not found
TLNAPI bool TLN_DeleteSpriteset ( TLN_Spriteset  spriteset)

Deletes the specified spriteset and frees memory.

Parameters
spritesetSpriteset to delete
Remarks
Don't delete a spriteset currently attached to a sprite!
See also
TLN_LoadSpriteset(), TLN_CloneSpriteset()
TLNAPI TLN_Tileset TLN_CreateTileset ( int  numtiles,
int  width,
int  height,
TLN_Palette  palette,
TLN_SequencePack  sp,
uint8_t *  types 
)

Creates a new tileset.

Parameters
numtilesNumber of tiles that the tileset will hold
widthWidth of each tile (must be multiple of 8)
heightHeight of each tile (must be multiple of 8)
paletteReference to the palette to assign
spOptional reference to the optional sequence pack with associated tileset animations, can be NULL
typesOptional array of bytes with the type of ecah tile, can be NULL
Returns
Reference to the created tileset, or NULL if error
See also
TLN_SetTilesetPixels()
TLNAPI TLN_Tileset TLN_LoadTileset ( const char *  filename)

Loads a tileset from a Tiled .tsx file.

Parameters
filenameTSX file to load
Returns
Reference to the newly loaded tileset or NULL if error
Remarks
An associated palette is also created, it can be obtained calling TLN_GetTilesetPalette()
TLNAPI TLN_Tileset TLN_CloneTileset ( TLN_Tileset  src)

Creates a duplicate of the specified tileset and its associated palette.

Parameters
srcTileset to clone
Returns
A reference to the newly cloned tileset, or NULL if error
See also
TLN_LoadTileset()
TLNAPI bool TLN_SetTilesetPixels ( TLN_Tileset  tileset,
int  entry,
uint8_t *  srcdata,
int  srcpitch 
)

Sets pixel data for a tile in a tileset.

Parameters
tilesetReference to the tileset
entryNumber of tile to set [0, num_tiles - 1]
srcdataPointer to pixel data to set
srcpitchBytes per line of source data
Returns
true if success, or false if error
Remarks
Care must be taken in providing pixel data and pitch as it can crash the aplication
See also
TLN_CreateTileset()
TLNAPI bool TLN_CopyTile ( TLN_Tileset  tileset,
int  src,
int  dst 
)

Copies tile graphic data inside a Tileset specified tileset.

Parameters
tilesetReference to the tileset to get the palette
srcindex of source tile
dstindex of target tile
TLNAPI int TLN_GetTileWidth ( TLN_Tileset  tileset)

Returns the width in pixels of each individual tile in the tileset.

Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileHeight()
TLNAPI int TLN_GetTileHeight ( TLN_Tileset  tileset)

Returns the height in pixels of each individual tile in the tileset.

Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileWidth()
TLNAPI TLN_Palette TLN_GetTilesetPalette ( TLN_Tileset  tileset)

Returns a reference to the palette associated to the specified tileset.

Parameters
tilesetReference to the tileset to get the palette
Remarks
The palette of a tileset is created at load time and cannot be modified. When TLN_SetLayer function is used to attach a tileset to a layer, the palette associated with the specified tileset is automatically assigned to that layer, but it can be later replaced with TLN_SetLayerPalette
See also
TLN_LoadTileset(), TLN_SetLayerPalette()
TLNAPI TLN_SequencePack TLN_GetTilesetSequencePack ( TLN_Tileset  tileset)

Returns a reference to the optional sequence pack associated to the specified tileset.

Parameters
tilesetReference to the tileset to get the palette
See also
TLN_LoadTileset(), TLN_CreateTileset()
TLNAPI bool TLN_DeleteTileset ( TLN_Tileset  tileset)

Deletes the specified tileset and frees memory.

Parameters
tilesetTileset to delete
Remarks
Don't delete a tileset currently attached to a layer!
See also
TLN_LoadTileset(), TLN_CloneTileset()
TLNAPI TLN_Tilemap TLN_CreateTilemap ( int  rows,
int  cols,
TLN_Tile  tiles,
uint32_t  bgcolor,
TLN_Tileset  tileset 
)

Creates a new tilemap.

Parameters
rowsNumber of rows (vertical dimension)
colsNumber of cols (horizontal dimension)
tilesArray of tiles with data (see struct Tile)
bgcolorBackground color value (RGB32 packed)
tilesetOptional reference to associated tileset, can be NULL
Returns
Reference to the created tilemap, or NULL if error
Remarks
Make sure that the tiles[] array is has at least rows*cols items or application may crash
See also
TLN_DeleteTilemap(), struct Tile
TLNAPI TLN_Tilemap TLN_LoadTilemap ( const char *  filename,
const char *  layername 
)

Loads a tilemap layer from a Tiled .tmx file.

Parameters
filenameTMX file with the tilemap
layernameOptional name of the layer inside the tmx file to load. NULL to load the first layer
Returns
Reference to the newly loaded tilemap or NULL if error
Remarks
A tmx map file from Tiled can contain one or more layers, each with its own name. TLN_LoadTilemap() doesn't load a full tmx file, only the specified layer. The associated external tileset (TSX file) is also loaded and associated to the tilemap
TLNAPI TLN_Tilemap TLN_CloneTilemap ( TLN_Tilemap  src)

Creates a duplicate of the specified tilemap.

Parameters
srcReference to the tilemap to clone
Returns
A reference to the newly cloned tilemap, or NULL if error
See also
TLN_LoadTilemap()
TLNAPI int TLN_GetTilemapRows ( TLN_Tilemap  tilemap)

Returns the number of vertical tiles in the tilemap.

Parameters
tilemapReference of the tilemap to get info
See also
TLN_GetTilemapCols()
TLNAPI int TLN_GetTilemapCols ( TLN_Tilemap  tilemap)

Returns the number of horizontal tiles in the tilemap.

Parameters
tilemapReference of the tilemap to get info
See also
TLN_GetTilemapCols()
TLNAPI TLN_Tileset TLN_GetTilemapTileset ( TLN_Tilemap  tilemap)

Returns the optional associated tileset to the specified tilemap.

Parameters
tilemapReference of the tilemap to get info
See also
TLN_CreateTilemap(), TLN_LoadTilemap()
TLNAPI bool TLN_GetTilemapTile ( TLN_Tilemap  tilemap,
int  row,
int  col,
TLN_Tile  tile 
)

Gets data of a single tile inside a tilemap.

Parameters
tilemapReference of the tilemap to get the tile
rowVertical location of the tile (0 <= row < rows)
colHorizontal location of the tile (0 <= col < cols)
tileReference to an application-allocated struct Tile that will get the data
TLNAPI bool TLN_SetTilemapTile ( TLN_Tilemap  tilemap,
int  row,
int  col,
TLN_Tile  tile 
)

Sets a tile of a tilemap.

Parameters
tilemapReference to the tilemap
rowRow (vertical position) of the tile [0 - num_rows - 1]
colColumn (horizontal position) of the tile [0 - num_cols - 1]
tileReference to the tile to set
Returns
true (success) or false (error)
TLNAPI bool TLN_CopyTiles ( TLN_Tilemap  src,
int  srcrow,
int  srccol,
int  rows,
int  cols,
TLN_Tilemap  dst,
int  dstrow,
int  dstcol 
)

Copies blocks of tiles between two tilemaps.

Parameters
srcReference to the source tilemap
srcrowStarting row (vertical position) inside the source tilemap
srccolStarting column (horizontal position) inside the source tilemap
rowsNumber of rows to copy
colsNumber of columns to copy
dstReference to the target tilemap
dstrowStarting row (vertical position) inside the target tilemap
dstcolStarting column (horizontal position) inside the target tilemap
Remarks
Use this function to implement tile streaming
TLNAPI bool TLN_DeleteTilemap ( TLN_Tilemap  tilemap)

Deletes the specified tilemap and frees memory.

Parameters
tilemapReference to the tilemap to delete
Remarks
Don't delete a tilemap currently attached to a layer!
See also
TLN_LoadTilemap(), TLN_CloneTilemap()
TLNAPI TLN_Palette TLN_CreatePalette ( int  entries)

Creates a new color table.

Parameters
entriesNumber of color entries (typically 256)
Returns
Reference to the created palette or NULL if error
TLNAPI TLN_Palette TLN_LoadPalette ( const char *  filename)

Loads a palette from a standard .act file.

Parameters
filenameACT file containing the palette to load
Returns
A reference to the newly loaded palette, or NULL if error
Remarks
Palettes are also automatically created when loading tilesets and spritesets. Use the functions TLN_GetTilesetPalette() and TLN_GetSpritesetPalette() to retrieve them.
See also
TLN_GetTilesetPalette(), TLN_GetSpritesetPalette()
TLNAPI TLN_Palette TLN_ClonePalette ( TLN_Palette  src)

Creates a duplicate of the specified palette.

Parameters
srcReference to the palette to clone
Returns
A reference to the newly cloned palette, or NULL if error
See also
TLN_CreatePalette()
TLNAPI bool TLN_SetPaletteColor ( TLN_Palette  palette,
int  index,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the RGB color value of a palette entry.

Parameters
paletteReference to the palette to modify
indexIndex of the palette entry to modify (0-255)
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
TLNAPI bool TLN_MixPalettes ( TLN_Palette  src1,
TLN_Palette  src2,
TLN_Palette  dst,
uint8_t  factor 
)

Mixes two palettes to create a third one.

Parameters
src1Reference to the first source palette
src2Reference to the second source palette
dstReference to the target palette
factorInteger with mixing factor. 0=100% src1, 255=100% src2, 128=50%/50%
TLNAPI bool TLN_AddPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by adding the provided color value to the selected range. The result is always a brighter color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify
TLNAPI bool TLN_SubPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by subtracting the provided color value to the selected range. The result is always a darker color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify
TLNAPI bool TLN_ModPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by modulating (normalized product) the provided color value to the selected range. The result is always a darker color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify
TLNAPI uint8_t* TLN_GetPaletteData ( TLN_Palette  palette,
int  index 
)

Returns the color value of a palette entry.

Parameters
paletteReference to the palette to get the color
indexIndex of the palette entry to obtain (0-255)
Returns
32-bit integer with the packed color in internal pixel format RGBA
TLNAPI bool TLN_DeletePalette ( TLN_Palette  palette)

Deletes the specified palette and frees memory.

Parameters
paletteReference to the palette to delete
Remarks
Don't delete a palette currently attached to a layer or sprite!
TLNAPI TLN_Bitmap TLN_CreateBitmap ( int  width,
int  height,
int  bpp 
)

Creates a memory bitmap.

Parameters
widthWidth in pixels
heightHeight in pixels
bppBits per pixel
Returns
Reference to the created bitmap, or NULL if error
See also
TLN_SetBGBitmap()
TLNAPI TLN_Bitmap TLN_LoadBitmap ( const char *  filename)

Load image file (8-bit BMP or PNG)

Parameters
filenameFile name with the image
Returns
Handler to the loaded image or NULL if error
See also
TLN_DeleteBitmap()
TLNAPI TLN_Bitmap TLN_CloneBitmap ( TLN_Bitmap  src)

Creates a copy of a bitmap.

Parameters
srcReference to the original bitmap
Returns
Reference to the created bitmap, or NULL if error
See also
TLN_SetBGBitmap()
TLNAPI uint8_t* TLN_GetBitmapPtr ( TLN_Bitmap  bitmap,
int  x,
int  y 
)

Gets memory access for direct pixel manipulation.

Parameters
bitmapReference to bitmap
xStarting x position [0, width - 1]
yStarting y position [0, height - 1]
Returns
Pointer to pixel data starting at x,y
Remarks
Care must be taken in manipulating memory directly as it can crash the application
TLNAPI int TLN_GetBitmapWidth ( TLN_Bitmap  bitmap)

Returns the width in pixels.

Parameters
bitmapReference to the bitmap
TLNAPI int TLN_GetBitmapHeight ( TLN_Bitmap  bitmap)

Returns the height in pixels.

Parameters
bitmapReference to the bitmap
TLNAPI int TLN_GetBitmapDepth ( TLN_Bitmap  bitmap)

Returns the bits per pixel.

Parameters
bitmapReference to the bitmap
TLNAPI int TLN_GetBitmapPitch ( TLN_Bitmap  bitmap)

Returns the number of bytes per scaline (also known a stride)

Parameters
bitmapReference to the bitmap
TLNAPI TLN_Palette TLN_GetBitmapPalette ( TLN_Bitmap  bitmap)

Gets the associated palete of a bitmap.

Parameters
bitmapReference to bitmap
Returns
Reference to the bitmap palette
See also
TLN_SetBitmapPalette()
TLNAPI bool TLN_SetBitmapPalette ( TLN_Bitmap  bitmap,
TLN_Palette  palette 
)

Assigns a new palette to the bitmap.

Parameters
bitmapReference to the bitmap
paletteReference to the palette to assign
See also
TLN_GetBitmapPalette()
TLNAPI bool TLN_DeleteBitmap ( TLN_Bitmap  bitmap)

Deletes bitmap and frees resources.

Parameters
bitmapReference to bitmap to delete
See also
TLN_CreateBitmap89, TLN_CloneBitmap()
TLNAPI bool TLN_SetLayer ( int  nlayer,
TLN_Tileset  tileset,
TLN_Tilemap  tilemap 
)

Configures a background layer with the specified tileset and tilemap.

Parameters
nlayerLayer index [0, num_layers - 1]
tilesetOptional reference to the tileset to assign. If the tilemap has a reference to its own tileset, passing NULL will assign the default tileset.
tilemapReference to the tilemap to assign
Remarks
This function doesn't modify the current position nor the blend mode, but assigns the palette of the specified tileset
See also
TLN_DisableLayer()
TLNAPI bool TLN_SetLayerPalette ( int  nlayer,
TLN_Palette  palette 
)

Sets the color palette to the layer.

Parameters
nlayerLayer index [0, num_layers - 1]
paletteReference to the palette to assign to the layer

When a layer is assigned with a tileset with the function TLN_SetLayer(), it automatically sets the palette of the assigned tileset to the layer. Use this function to override it and set another palette

Remarks
Call this function inside a raster callback to change the palette in the middle of the frame to get raster effect colors, like and "underwater" palette below the water line in a partially submerged background, or a gradient palette in an area at the top of the screen to simulate a "depth fog effect" in a pseudo 3d background
TLNAPI bool TLN_SetLayerPosition ( int  nlayer,
int  hstart,
int  vstart 
)

Sets the position of the tileset that corresponds to the upper left corner.

Parameters
nlayerLayer index [0, num_layers - 1]
hstartHorizontal offset in the tileset on the left side
vstartVertical offset in the tileset on the top side

The tileset usually spans an area much bigger than the viewport. Use this function to move the viewport insde the tileset. Change this value progressively for each frame to get a scrolling effect

Remarks
Call this function inside a raster callback to get a raster scrolling effect. Use this to create horizontal strips of the same layer that move at different speeds to simulate depth. The extreme case of this effect, where the position is changed in each scanline, is called "line scroll" and was the technique used by games such as Street Fighter II to simualte a pseudo 3d floor, or many racing games to simulate a 3D road.
TLNAPI bool TLN_SetLayerScaling ( int  nlayer,
float  sx,
float  sy 
)

Sets simple scaling.

Parameters
nlayerLayer index [0, num_layers - 1]
sxHorizontal scale factor
syVertical scale factor

By default the scaling factor of a given layer is 1.0f, 1.0f, which means no scaling. Use values below 1.0 to downscale (shrink) and above 1.0 to upscale (enlarge). Call TLN_ResetLayerMode() to disable scaling

Write detailed description for TLN_SetLayerScaling here.

See also
TLN_ResetLayerMode()
TLNAPI bool TLN_SetLayerAffineTransform ( int  nlayer,
TLN_Affine affine 
)

Sets affine transform matrix to enable rotating and scaling of this layer.

Parameters
nlayerLayer index [0, num_layers - 1]
affinePointer to an TLN_Affine matrix, or NULL to disable it

Enable the transformation matrix to give the layer the capabilities of the famous Super Nintendo / Famicom Mode 7. Beware that the rendering of a transformed layer uses more CPU than a regular layer. Unlike the original Mode 7, that could only transform the single layer available, Tilengine can transform all the layers at the same time. The only limitation is the available CPU power.

Remarks
Call this function inside a raster callback to set the transformation matrix in the middle of the frame. Setting it for each scanline is the trick used by many Super Nintendo games to fake a 3D perspective projection.
See also
TLN_SetLayerTransform()
TLNAPI bool TLN_SetLayerTransform ( int  layer,
float  angle,
float  dx,
float  dy,
float  sx,
float  sy 
)

Sets affine transform matrix to enable rotating and scaling of this layer.

Parameters
layerLayer index [0, num_layers - 1]
angleRotation angle in degrees
dxHorizontal displacement
dyVertical displacement
sxHorizontal scaling
syVertical scaling
Remarks
This function is a simple wrapper to TLN_SetLayerAffineTransform() without using the TLN_Affine struct
See also
TLN_SetLayerAffineTransform()
TLNAPI bool TLN_SetLayerPixelMapping ( int  nlayer,
TLN_PixelMap table 
)

Sets the table for pixel mapping render mode.

Parameters
nlayerLayer index [0, num_layers - 1]
tableUser-provided array of hres*vres sized TLN_PixelMap items
See also
TLN_SetLayerScaling(), TLN_SetLayerAffineTransform()
TLNAPI bool TLN_SetLayerBlendMode ( int  nlayer,
TLN_Blend  mode,
uint8_t  factor 
)

Sets the blending mode (transparency effect)

Parameters
nlayerLayer index [0, num_layers - 1]
modeMember of the TLN_Blend enumeration
factorDeprecated as of 1.12, left for backwards compatibility but doesn't have effect.
See also
Blending
TLNAPI bool TLN_SetLayerColumnOffset ( int  nlayer,
int *  offset 
)

Enables column offset mode for this layer.

Parameters
nlayerLayer index [0, num_layers - 1]
offsetArray of offsets to set. Set NULL to disable column offset mode

Column offset is a value that is added or substracted (depeinding on the sign) to the vertical position for that layer (see TLN_SetLayerPosition) for each column in the tilemap assigned to that layer.

Remarks
This feature is tipically used to simulate vertical strips moving at different speeds, or combined with a line scroll effect, to fake rotations where the angle is small. The Sega Genesis games Puggsy and Chuck Rock II used this trick to simulate partially rotating backgrounds
TLNAPI bool TLN_SetLayerClip ( int  nlayer,
int  x1,
int  y1,
int  x2,
int  y2 
)

Enables clipping rectangle on selected layer.

Parameters
nlayerLayer index [0, num_layers - 1]
x1left coordinate
y1top coordinate
x2right coordinate
y2bottom coordinate
See also
TLN_DisableLayerClip()
TLNAPI bool TLN_DisableLayerClip ( int  nlayer)

Disables clipping rectangle on selected layer.

Parameters
nlayerLayer index [0, num_layers - 1]
See also
TLN_SetLayerClip()
TLNAPI bool TLN_SetLayerMosaic ( int  nlayer,
int  width,
int  height 
)

Enables mosaic effect (pixelation) for selected layer.

Parameters
nlayerLayer index [0, num_layers - 1]
widthhorizontal pixel size
heightvertical pixel size
See also
TLN_DisableLayerMosaic()
TLNAPI bool TLN_DisableLayerMosaic ( int  nlayer)

Disables mosaic effect for selected layer.

Parameters
nlayerLayer index [0, num_layers - 1]
See also
TLN_SetLayerMosaic()
TLNAPI bool TLN_ResetLayerMode ( int  nlayer)

Disables scaling or affine transform for the layer.

Parameters
nlayerLayer index [0, num_layers - 1]

Write detailed description for TLN_ResetLayerMode here.

See also
TLN_SetLayerScaling(), TLN_SetLayerAffineTransform()
TLNAPI bool TLN_DisableLayer ( int  nlayer)

Disables the specified layer so it is not drawn.

Parameters
nlayerLayer index [0, num_layers - 1]
Remarks
A layer configured with an invalid tileset, tilemap or palette is automatically disabled
See also
TLN_SetLayer()
TLNAPI TLN_Palette TLN_GetLayerPalette ( int  nlayer)

Gets the attached palette of a layer.

Parameters
nlayerLayer index [0, num_layers - 1]
Returns
Reference of the palette assigned to the layer
See also
TLN_SetLayerPalette()
TLNAPI bool TLN_GetLayerTile ( int  nlayer,
int  x,
int  y,
TLN_TileInfo info 
)

Gets info about the tile located in tilemap space.

Parameters
nlayerId of the layer to query [0, num_layers - 1]
xx position
yy position
infoPointer to an application-allocated TLN_TileInfo struct that will get the data
Returns
true if success or false if error
Remarks
Use this function to implement collision detection between sprites and the main background layer.
See also
TLN_TileInfo
TLNAPI int TLN_GetLayerWidth ( int  nlayer)

Returns the layer width in pixels.

Parameters
nlayerLayer index [0, num_layers - 1]
See also
TLN_SetLayer(), TLN_GetLayerHeight()
TLNAPI int TLN_GetLayerHeight ( int  nlayer)

Returns the layer height in pixels.

Parameters
nlayerLayer index [0, num_layers - 1]
See also
TLN_SetLayer(), TLN_GetLayerWidth()
TLNAPI bool TLN_ConfigSprite ( int  nsprite,
TLN_Spriteset  spriteset,
TLN_TileFlags  flags 
)

Configures a sprite, setting setting spriteset and flags at once.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
spritesetReference of the spriteset containing the graphics to set
flagsCan be 0 or a combination of FLAG_FLIPX and FLAG_FLIPY
Remarks
This function also assigns the palette of the spriteset
See also
TLN_SetSpritePicture()
TLNAPI bool TLN_SetSpriteSet ( int  nsprite,
TLN_Spriteset  spriteset 
)

Assigns the spriteset and its palette to a given sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
spritesetReference of the spriteset containing the graphics to set
Remarks
This function also assigns the palette of the spriteset
See also
TLN_SetSpritePicture()
TLNAPI bool TLN_SetSpriteFlags ( int  nsprite,
TLN_TileFlags  flags 
)

Sets flags for a given sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
flagsCan be 0 or a combination of FLAG_FLIPX and FLAG_FLIPY
TLNAPI bool TLN_SetSpritePosition ( int  nsprite,
int  x,
int  y 
)

Sets the sprite position inside the viewport.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
xHorizontal position (0 = left margin)
yVertical position (0 = top margin)
Remarks
Call this function inside a raster callback to so some vertical distortion effects (fake scaling) or sprite multiplexing (reusing a single sprite at different screen heights). This technique was used by some 8 bit games, with very few hardware sprites, to draw much more sprites in the screen, as long as they don't overlap vertically
TLNAPI bool TLN_SetSpritePicture ( int  nsprite,
int  entry 
)

Sets the actual graphic to the sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
entryIndex of the actual picture inside the srpteset to assign (0 <= entry < num_spriteset_graphics)

To show a sprite, at least two function calls are needed: first call TLN_ConfigSprite to assign the spriteset containing the graphics, and then call TLN_SetSpritePicture to assign the actual graphic. Usually all the frames for a given character are contained inside the same spriteset, so it is only needed to configure the sprite once at the beginning for a particular character, and then just reassign the graphic

See also
TLN_ConfigSprite(), TLN_SetSpriteSet(), TLN_SetSpritePictureByName()
TLNAPI bool TLN_SetSpritePalette ( int  nsprite,
TLN_Palette  palette 
)

Assigns a palette to a sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
paletteReference of the palete to assign

Write detailed description for TLN_SetSpritePalette here.

Remarks
When a sprite is configured with a spriteset with the function TLN_ConfigSprite(), it automatically sets the palette of the assigned spriteset to the sprite. Use this function to override it and set another palette
TLNAPI bool TLN_SetSpriteBlendMode ( int  nsprite,
TLN_Blend  mode,
uint8_t  factor 
)

Sets the blending mode (transparency effect)

Parameters
nspriteId of the sprite [0, num_sprites - 1]
modeMember of the TLN_Blend enumeration
factorDeprecated as of 1.12, left for backwards compatibility but doesn't have effect.
See also
Blending
TLNAPI bool TLN_SetSpriteScaling ( int  nsprite,
float  sx,
float  sy 
)

Sets the scaling factor of the sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
sxHorizontal scale factor
syVertical scale factor

By default the scaling factor of a given sprite is 1.0f, 1.0f, which means no scaling. Use values below 1.0 to downscale (shrink) and above 1.0 to upscale (enlarge). Call TLN_ResetScaling() to disable scaling

Remarks
The rendering of a sprite with scaling enabled requires somewhat more CPU power than a regular sprite.
See also
TLN_ResetSpriteScaling()
TLNAPI bool TLN_ResetSpriteScaling ( int  nsprite)

Disables scaling for a given sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
See also
TLN_SetSpriteScaling()
TLNAPI int TLN_GetSpritePicture ( int  nsprite)

Returns the index of the assigned picture from the spriteset.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
See also
TLN_SetSpritePicture()
TLNAPI int TLN_GetAvailableSprite ( void  )

Finds an available (unused) sprite.

Returns
Index of the first unused sprite (starting from 0) or -1 if none found
TLNAPI bool TLN_EnableSpriteCollision ( int  nsprite,
bool  enable 
)

Enable sprite collision checking at pixel level.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
enableSet true to enable o false to disable (default value)
Remarks
Only sprites that have collision enabled are checked between them, so to detect a collision between two sprites, both of them must have collision detection enabled. Processing collision detection sprites take more a bit more CPU time compared to non-colliding sprites, so by default it is disabled on all sprites.
See also
TLN_GetSpriteCollision()
TLNAPI bool TLN_GetSpriteCollision ( int  nsprite)

Gets the collision status of a given sprite.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
Returns
Tue if this sprite is involved in a collision with another sprite
Remarks
Collision detection must be enabled for the sprite to get checked
See also
TLN_EnableSpriteCollision()
TLNAPI bool TLN_DisableSprite ( int  nsprite)

Disables the sprite so it is not drawn.

Parameters
nspriteId of the sprite [0, num_sprites - 1]
Remarks
A sprite is also automatically disabled when assigned with an invalid spriteste or palette. Disabled sprites are returned by the function TLN_GetAvailableSprite as available
TLNAPI TLN_Palette TLN_GetSpritePalette ( int  nsprite)

Gets the palette assigned to a given sprite.

Parameters
nspriteId of the sprite to query (0 <= id < max_sprites)
Returns
Reference to the sprite palette
See also
TLN_SetSpritePalette(), TLN_SetSpriteSet()
TLNAPI TLN_Sequence TLN_CreateSequence ( const char *  name,
int  target,
int  count,
TLN_SequenceFrame frames 
)

Creates a new sequence for the animation engine.

Parameters
nameString with an unique name to query later
targetFor tileset animations, the tile index to animate
countNumber of frames
framesArray of TLN_Frame items with indexes and delays
Returns
Reference to the new sequence or NULL if error
Remarks
Use this function to create tileset or sprite animations
See also
TLN_SetTilemapAnimation(), TLN_SetSpriteAnimation()
TLNAPI TLN_Sequence TLN_CreateCycle ( const char *  name,
int  count,
TLN_ColorStrip strips 
)

Creates a color cycle sequence for palette animation.

Parameters
nameString with an unique name to query later
countNumber of color strips
stripsArray of color strips to assign
Returns
Reference to the created cycle or NULL if error
Remarks
Use this function to create advanced palette animation effects
See also
TLN_ColorStrip(), TLN_SetPaletteAnimation()
TLNAPI TLN_Sequence TLN_CloneSequence ( TLN_Sequence  src)

Creates a duplicate of the specified sequence.

Parameters
srcSequence to clone
Returns
A reference to the newly cloned sequence, or NULL if error
See also
TLN_FindSequence()
TLNAPI bool TLN_DeleteSequence ( TLN_Sequence  sequence)

Deletes the sequence and frees resources.

Parameters
sequenceReference to the sequence to be deleted
Remarks
Don't delete an active sequence!
TLNAPI TLN_SequencePack TLN_CreateSequencePack ( void  )

Creates a new collection of sequences.

Returns
Reference to the created pack or NULL if error
See also
TLN_AddSequenceToPack(), TLN_CreateSequence()
TLNAPI TLN_SequencePack TLN_LoadSequencePack ( const char *  filename)

Loads a sqx file containing one or more sequences.

Parameters
filenameSQX filename with the sequences to load
Returns
Reference to the newly created TLN_SequencePack() or NULL if error
Remarks
A SQX file can contain many sequences. This function loads all of them inside a single TLN_SequencePack(). Individual sequences can be later queried with TLN_FindSequence()
See also
TLN_FindSequence()
TLNAPI TLN_Sequence TLN_GetSequence ( TLN_SequencePack  sp,
int  index 
)

Returns the nth sequence inside a sequence pack.

Parameters
spReference to the sequence pack containing the sequence to find
indexSequence number to return [0, num_sequences - 1]
See also
TLN_LoadSequencePack(), TLN_GetSequencePackCount()
TLNAPI TLN_Sequence TLN_FindSequence ( TLN_SequencePack  sp,
const char *  name 
)

Finds a sequence inside a sequence pack.

Parameters
spReference to the sequence pack containing the sequence to find
nameName of the sequence to find
Returns
Reference to the sequence with the specified name, or NULL if not found
See also
TLN_LoadSequencePack()
TLNAPI int TLN_GetSequencePackCount ( TLN_SequencePack  sp)

Returns the number of sequences inside a sequence pack.

Parameters
spReference to the sequence pack to query
TLNAPI bool TLN_AddSequenceToPack ( TLN_SequencePack  sp,
TLN_Sequence  sequence 
)

Adds a sequence to a sequence pack.

Parameters
spReference to the sequence pack
sequenceReference to the sequence to attach
Remarks
Write remarks for TLN_AddSequenceToPack here.
See also
TLN_CreateSequencePack(), TLN_CreateSequence()
TLNAPI bool TLN_DeleteSequencePack ( TLN_SequencePack  sp)

Deletes the specified sequence pack and frees memory.

Parameters
spReference to the sequence pack to delete
Remarks
Don't delete a sequence pack that has sequences currently attached to animations! The attached sequences are also deleted, so they haven't to be deleted externally.
See also
TLN_LoadSequencePack()
TLNAPI bool TLN_SetPaletteAnimation ( int  index,
TLN_Palette  palette,
TLN_Sequence  sequence,
bool  blend 
)

Starts a palette animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
paletteReference of the palette to be animated
sequenceReference of the sequence to assign
blendtrue for smooth frame interpolation, false for classic, discrete mode
TLNAPI bool TLN_SetPaletteAnimationSource ( int  index,
TLN_Palette  palette 
)

Sets the source palette of a color cycle animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
paletteReference of the palette to assign
Remarks
Use this function to change the palette assigned to a color cycle animation running. This is useful to combine color cycling and palette interpolation at the same time
TLNAPI bool TLN_SetTilesetAnimation ( int  index,
int  nlayer,
TLN_Sequence  sequence 
)

Starts a tileset animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
nlayerId of the layer to animate (0 <= id < num_layers)
sequenceReference of the sequence to assign
See also
Animations
TLNAPI bool TLN_SetTilemapAnimation ( int  index,
int  nlayer,
TLN_Sequence  sequence 
)

Starts a tilemap animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
nlayerId of the layer to animate (0 <= id < num_layers)
sequenceReference of the sequence to assign
See also
Animations
TLNAPI bool TLN_SetSpriteAnimation ( int  index,
int  nsprite,
TLN_Sequence  sequence,
int  loop 
)

Starts a sprite animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
nspriteIf of the sprite to animate (0 <= id < num_sprites)
sequenceReference of the sequence to assign
loopamount of times to loop, 0=infinite
See also
Animations
TLNAPI bool TLN_GetAnimationState ( int  index)

Checks the state of the specified animation.

Parameters
indexId of the animation to check (0 <= id < num_animations)
Returns
true if animation is running, false if it's finished or inactive
TLNAPI bool TLN_SetAnimationDelay ( int  index,
int  delay 
)

Sets the playback speed of a given animation.

Parameters
indexId of the animation to set (0 <= id < num_animations)
delayNew delay between frames to assign

Each sequence has its own delay set in the sqx file. However sometimes it's convenient to speed up or down the playback speed in realtime, for example for a character that is accelerating.

Remarks
The meaning of the delay value (i.e. its units) is application dependant. It can usually be frames or milliseconds. Make sure that its units match the ones insode the sqx file and the ones passed to the TLN_UpdateFrame()
See also
Animations, TLN_UpdateFrame()
TLNAPI int TLN_GetAvailableAnimation ( void  )

Finds an available (unused) animation.

Returns
Index of the first unused animation (starting from 0) or -1 if none found
TLNAPI bool TLN_DisableAnimation ( int  index)

Disables the animation so it stops playing and returns it to the list of available animations.

Parameters
indexId of the animation to set (0 <= id < num_animations)
See also
Animations