Skip to content

Commit

Permalink
Release 2.8.0 - revamped animation system
Browse files Browse the repository at this point in the history
* Slotted animation accounts only for palette (color cycle animations).
* Tileset and sprite animations are self-sustained and don't use shared slots anymore.
* Removed legacy unused "tilemap" animation type
* Breaking API changes: removed TLN_SetTilesetAnimation() and TLN_SetTilemapAnimation(). Removed parameter "index" from TLN_SetSpriteAnimation(), requires only sprite number. Replaces TLN_DisableAnimation() with TLN_DisablePaletteAnimation() and TLN_DisableSpriteAnimation()
* Cached Tileset loader in case a tilemap sues the same tileset on multiple layers
* Updated all samples to the modified animation API
  • Loading branch information
megamarc committed May 1, 2020
1 parent 944cc8a commit e08b366
Show file tree
Hide file tree
Showing 26 changed files with 448 additions and 329 deletions.
11 changes: 5 additions & 6 deletions include/Tilengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

/* version */
#define TILENGINE_VER_MAJ 2
#define TILENGINE_VER_MIN 7
#define TILENGINE_VER_REV 6
#define TILENGINE_VER_MIN 8
#define TILENGINE_VER_REV 0
#define TILENGINE_HEADER_VERSION ((TILENGINE_VER_MAJ << 16) | (TILENGINE_VER_MIN << 8) | TILENGINE_VER_REV)

#define BITVAL(n) (1<<(n))
Expand Down Expand Up @@ -626,13 +626,12 @@ TLNAPI bool TLN_DeleteSequencePack (TLN_SequencePack sp);
* @{ */
TLNAPI bool TLN_SetPaletteAnimation (int index, TLN_Palette palette, TLN_Sequence sequence, bool blend);
TLNAPI bool TLN_SetPaletteAnimationSource (int index, TLN_Palette);
TLNAPI bool TLN_SetTilesetAnimation (int index, int nlayer, TLN_Sequence);
TLNAPI bool TLN_SetTilemapAnimation (int index, int nlayer, TLN_Sequence);
TLNAPI bool TLN_SetSpriteAnimation (int index, int nsprite, TLN_Sequence sequence, int loop);
TLNAPI bool TLN_SetSpriteAnimation (int nsprite, TLN_Sequence sequence, int loop);
TLNAPI bool TLN_GetAnimationState (int index);
TLNAPI bool TLN_SetAnimationDelay (int index, int delay);
TLNAPI int TLN_GetAvailableAnimation (void);
TLNAPI bool TLN_DisableAnimation (int index);
TLNAPI bool TLN_DisablePaletteAnimation(int index);
TLNAPI bool TLN_DisableSpriteAnimation(int index);
/**@}*/

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion samples/Actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ static void TasksActor (Actor* actor)
else
{
TLN_DisableSprite (actor->index);
TLN_DisableAnimation (actor->index);
TLN_DisableSpriteAnimation (actor->index);
}
}
2 changes: 1 addition & 1 deletion samples/Explosion.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Actor* CreateExplosion (int index, int x, int y, TLN_Sequence sequence)
Actor* actor = GetActor (index);
SetActor (index, TYPE_EXPLOSION, x,y, 32,32, ExplosionTasks);
TLN_ConfigSprite (index, spritesets[SPRITESET_MAIN], 0);
TLN_SetSpriteAnimation (index, index, sequence, 1);
TLN_SetSpriteAnimation (index, sequence, 1);
//TLN_SetSpriteBlendMode (index, BLEND_ADD);
return actor;
}
4 changes: 2 additions & 2 deletions samples/Forest.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char* argv[])
if (argc > 2)
passkey = argv[2];

TLN_Init(HRES, VRES, NUM_LAYERS, 8, 8);
TLN_Init(HRES, VRES, NUM_LAYERS, 8, 0);

/* load assets */
TLN_SetLogLevel(TLN_LOG_ERRORS);
Expand Down Expand Up @@ -109,7 +109,7 @@ int main(int argc, char* argv[])
xplayer = 48;
yplayer = 144;
TLN_ConfigSprite(0, atlas, 0);
TLN_SetSpriteAnimation(0, 0, idle, 0);
TLN_SetSpriteAnimation(0, idle, 0);

/* create window & main loop */
TLN_CreateWindow(NULL, 0);
Expand Down
2 changes: 1 addition & 1 deletion samples/Mode7.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void raster_callback (int line);
int main (int argc, char* argv[])
{
/* setup engine */
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, 0, 5);
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, 0, 0);
TLN_SetRasterCallback (raster_callback);
TLN_SetBGColor (0,0,0);

Expand Down
2 changes: 1 addition & 1 deletion samples/Platformer.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main (int argc, char *argv[])
TLN_Palette palette;

/* setup engine */
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, 0, 20);
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, 0, 1);
TLN_SetRasterCallback (raster_callback);
TLN_SetBGColor (0,128,238);

Expand Down
4 changes: 2 additions & 2 deletions samples/Shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main (int argc, char* argv[])
TLN_Sequence walk;

/* setup engine */
TLN_Init (WIDTH, HEIGHT, 2,1,1);
TLN_Init (WIDTH, HEIGHT, 2,1,0);
TLN_SetBGColor (0,128,238);
TLN_SetRasterCallback (raster_callback);

Expand All @@ -65,7 +65,7 @@ int main (int argc, char* argv[])

TLN_ConfigSprite (0, spriteset, 0);
TLN_SetSpritePosition (0, 200,160);
TLN_SetSpriteAnimation (0, 0, walk, 0);
TLN_SetSpriteAnimation (0, walk, 0);

xpos = 2000;

Expand Down
4 changes: 2 additions & 2 deletions samples/Ship.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Actor* CreateClaw (int id)
Claw* claw = (Claw*)actor->usrdata;

TLN_ConfigSprite (actor->index, spritesets[SPRITESET_MAIN], 0);
TLN_SetSpriteAnimation (actor->index, actor->index, sequences[SEQ_CLAW], 0);
TLN_SetSpriteAnimation (actor->index, sequences[SEQ_CLAW], 0);

claw->angle = id==ACTOR_CLAW1? 360:180;
claw->radius = 0;
Expand Down Expand Up @@ -197,7 +197,7 @@ Actor* CreateShot (int type, int x, int y)
actor->vx = 8;
actor->vy = 0;
TLN_ConfigSprite (actor->index, spritesets[SPRITESET_MAIN], 0);
TLN_SetSpriteAnimation (actor->index, actor->index, sequences[seq], 0);
TLN_SetSpriteAnimation (actor->index, sequences[seq], 0);

return actor;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/Shooter.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main (int argc, char *argv[])
int c;

/* setup engine */
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, MAX_ACTOR, MAX_ACTOR);
TLN_Init (WIDTH,HEIGHT, MAX_LAYER, MAX_ACTOR, 0);
TLN_SetRasterCallback (raster_callback);
TLN_SetBGColor (136,238,204);

Expand Down
6 changes: 3 additions & 3 deletions samples/Simon.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ void SimonSetState (int s)
switch (state)
{
case SIMON_IDLE:
TLN_DisableAnimation (0);
TLN_DisableSpriteAnimation (0);
TLN_SetSpritePicture (0, 0);
break;

case SIMON_WALKING:
TLN_SetSpriteAnimation (0, 0, walk, 0);
TLN_SetSpriteAnimation (0, walk, 0);
break;

case SIMON_JUMPING:
TLN_DisableAnimation (0);
TLN_DisableSpriteAnimation (0);
TLN_SetSpritePicture (0, 7);
sy = -18;
break;
Expand Down
4 changes: 2 additions & 2 deletions samples/SuperMarioClone.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main (int argc, char* argv[])
int player_y = 160;

/* basic setup */
TLN_Init (WIDTH, HEIGHT, MAX_LAYER,1,3);
TLN_Init (WIDTH, HEIGHT, MAX_LAYER,1,0);
TLN_SetBGColor (0, 96, 184);

/* load resources */
Expand All @@ -42,7 +42,7 @@ int main (int argc, char* argv[])

/* setup animations */
seq_walking = TLN_CreateSpriteSequence (NULL, spriteset, "walking", 6);
TLN_SetSpriteAnimation (2, 0, seq_walking, 0);
TLN_SetSpriteAnimation (0, seq_walking, 0);

/* main loop */
TLN_CreateWindow (NULL, 0);
Expand Down
Loading

0 comments on commit e08b366

Please sign in to comment.