2010-10-12 10:55:23 +02:00
|
|
|
|
/*
|
2019-08-03 19:43:48 +02: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
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2010-10-12 10:55:23 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2021-08-12 23:09:01 +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 AniSequence {
|
|
|
|
|
int length;
|
2020-01-04 02:03:08 +01:00
|
|
|
|
int frame_indices[];
|
2018-04-12 16:08:48 +02:00
|
|
|
|
} AniSequence;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
typedef struct Animation {
|
2018-06-29 23:36:51 +02:00
|
|
|
|
ht_str2ptr_t sequences;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
Sprite **sprites;
|
2020-01-04 02:03:08 +01:00
|
|
|
|
Sprite *local_sprites;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
int sprite_count;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
} Animation;
|
|
|
|
|
|
2020-06-09 03:33:22 +02:00
|
|
|
|
DEFINE_RESOURCE_GETTER(Animation, res_anim, RES_ANIM)
|
|
|
|
|
DEFINE_OPTIONAL_RESOURCE_GETTER(Animation, res_anim_optional, RES_ANIM)
|
2020-03-17 10:47:14 +01:00
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
|
AniSequence *get_ani_sequence(Animation *ani, const char *seqname);
|
|
|
|
|
|
2020-01-04 02:03:08 +01:00
|
|
|
|
// Returns a sprite for the specified frame from an animation sequence named seqname.
|
|
|
|
|
//
|
2018-04-12 16:08:48 +02:00
|
|
|
|
// 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.
|
2020-01-04 02:03:08 +01:00
|
|
|
|
//
|
2018-04-12 16:08:48 +02:00
|
|
|
|
// Note that seqframe loops (otherwise the example above wouldn’t work).
|
2020-01-04 02:03:08 +01:00
|
|
|
|
//
|
2018-04-12 16:08:48 +02:00
|
|
|
|
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"
|