2010-10-12 10:55:23 +02:00
|
|
|
|
/*
|
2011-03-05 13:44:21 +01:00
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
|
* See COPYING for further information.
|
2011-03-05 13:44:21 +01:00
|
|
|
|
* ---
|
2018-01-04 18:14:31 +01:00
|
|
|
|
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
|
|
|
|
|
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
|
2010-10-12 10:55:23 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2017-09-27 14:14:53 +02:00
|
|
|
|
#pragma once
|
2017-11-25 20:45:11 +01:00
|
|
|
|
#include "taisei.h"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
#include "resource.h"
|
2018-02-06 07:19:25 +01:00
|
|
|
|
#include "sprite.h"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
typedef struct AniSequenceFrame {
|
|
|
|
|
uint spriteidx;
|
|
|
|
|
bool mirrored;
|
|
|
|
|
} AniSequenceFrame;
|
2018-02-06 07:19:25 +01:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
typedef struct AniSequence {
|
|
|
|
|
AniSequenceFrame *frames;
|
|
|
|
|
int length;
|
|
|
|
|
} AniSequence;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
typedef struct Animation {
|
|
|
|
|
Hashtable *sequences;
|
|
|
|
|
|
|
|
|
|
Sprite **sprites;
|
|
|
|
|
Sprite transformed_sprite; // temporary sprite used to apply animation transformations.
|
|
|
|
|
int sprite_count;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
} Animation;
|
|
|
|
|
|
2017-03-02 11:23:30 +01:00
|
|
|
|
char* animation_path(const char *name);
|
|
|
|
|
bool check_animation_path(const char *path);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
void* load_animation_begin(const char *filename, uint flags);
|
|
|
|
|
void* load_animation_end(void *opaque, const char *filename, uint flags);
|
2018-02-06 07:19:25 +01:00
|
|
|
|
void unload_animation(void *vani);
|
2017-03-02 11:23:30 +01:00
|
|
|
|
|
2017-02-28 18:47:47 +01:00
|
|
|
|
Animation *get_ani(const char *name);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
AniSequence *get_ani_sequence(Animation *ani, const char *seqname);
|
|
|
|
|
|
|
|
|
|
// Returns a sprite for the specified frame from an animation sequence named seqname.
|
|
|
|
|
// CAUTION: this sprite is only valid until the next call to this function.
|
|
|
|
|
//
|
|
|
|
|
// The frames correspond 1:1 to real ingame frames, so
|
|
|
|
|
//
|
|
|
|
|
// draw_sprite_p(x, y, animation_get_frame(ani,"fly",global.frames));
|
|
|
|
|
//
|
|
|
|
|
// already gives you the fully functional animation rendering. You can use
|
|
|
|
|
// an AniPlayer instance for queueing.
|
|
|
|
|
//
|
|
|
|
|
// Note that seqframe loops (otherwise the example above wouldn’t work).
|
|
|
|
|
//
|
|
|
|
|
Sprite *animation_get_frame(Animation *ani, AniSequence *seq, int seqframe);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern ResourceHandler animation_res_handler;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
2017-03-02 11:23:30 +01:00
|
|
|
|
#define ANI_PATH_PREFIX TEX_PATH_PREFIX
|
2017-03-11 22:39:38 +01:00
|
|
|
|
#define ANI_EXTENSION ".ani"
|