taisei/src/aniplayer.h
Andrei Alexeyev e355e57fb5
make the list api require less insane casts all over the place
by sealing the spirit of insanity in its header file, that is
2017-12-24 08:16:25 +02:00

61 lines
1.8 KiB
C

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
*/
#pragma once
#include "taisei.h"
/*
* This is a helper to play animations. It saves the state of the animation and
* allows queueing different animation sequences.
*/
#include "resource/animation.h"
#include "stageobjects.h"
#include "list.h"
typedef struct AniSequence AniSequence;
struct AniSequence{
LIST_INTERFACE(AniSequence);
int row;
int duration; // number of frames this sequence will be drawn
int clock;
int delay; // after the sequence has played loops times before the next one is started.
int speed; // overrides ani->speed if > 0
bool mirrored;
bool backwards;
};
typedef struct AniPlayer AniPlayer;
struct AniPlayer{
OBJECT_INTERFACE(AniPlayer); // hack for the boss glow effect
Animation *ani;
int clock;
int stdrow; // this is the row rendered when the queue is empty
bool mirrored;
AniSequence *queue;
int queuesize;
};
void aniplayer_create(AniPlayer *plr, Animation *ani);
void aniplayer_free(AniPlayer *plr);
void aniplayer_reset(AniPlayer *plr); // resets to a neutral state with empty queue.
AniPlayer* aniplayer_create_copy(AniPlayer *src);
void aniplayer_free_copy(AniPlayer *ani);
AniSequence *aniplayer_queue(AniPlayer *plr, int row, int loops, int delay); // 0 loops: played one time
AniSequence *aniplayer_queue_pro(AniPlayer *plr, int row, int start, int duration, int delay, int speed); // self-documenting pro version
void aniplayer_update(AniPlayer *plr); // makes the inner clocks tick
void aniplayer_play(AniPlayer *plr, float x, float y);
void play_animation(Animation *ani, float x, float y, int row); // the old way to draw animations without AniPlayer