JNIEXPORT jboolean JNICALL Java_Tilengine_SetSpritePicture (JNIEnv* env, jobject thisobj, jint nsprite, jint index) { return TLN_SetSpritePicture (nsprite, index); }
/* main loop tasks */ void UpdateAnimations (int time) { int c; TLN_Sequence sequence; TLN_SequenceFrame* frames; struct Strip* strips; for (c=0; c<engine->numanimations; c++) { Animation* animation = &engine->animations[c]; if (animation->enabled==false) continue; sequence = animation->sequence; if (animation->type == TYPE_PALETTE) { int i; strips = (struct Strip*)&sequence->data; for (i=0; i<sequence->count; i++) { struct Strip* strip = &strips[i]; /* next frame */ if (time >= strip->timer) { strip->timer = time + strip->delay; strip->pos = (strip->pos + 1) % strip->count; strip->t0 = time; if (!animation->blend) ColorCycle (animation->srcpalette, animation->palette, strip); } /* interpolate */ if (animation->blend) ColorCycleBlend (animation->srcpalette, animation->palette, strip, time); } continue; } if (time < animation->timer) continue; frames = (TLN_SequenceFrame*)&sequence->data; animation->timer = time + frames[animation->pos].delay; switch (animation->type) { case TYPE_TILEMAP: ReplaceTiles (engine->layers[animation->idx].tilemap, frames[animation->pos].index, frames[animation->pos + 1].index % sequence->count); break; case TYPE_SPRITE: TLN_SetSpritePicture (animation->idx, frames[animation->pos].index); break; case TYPE_TILESET: TLN_CopyTile (engine->layers[animation->idx].tileset, frames[animation->pos].index, sequence->target); break; } /* next frame */ animation->pos++; if (animation->pos == sequence->count) { if (animation->loop > 1) { animation->loop--; animation->pos = 0; } else if (animation->loop == 1) animation->enabled = false; else if (animation->loop == 0) animation->pos = 0; } } }