51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
#ifndef _MYSTNB_ANIMATION_H
|
|
#define _MYSTNB_ANIMATION_H
|
|
|
|
#include <gint/display.h>
|
|
|
|
struct anim_data;
|
|
|
|
/* anim_function_t: Update function for each animation */
|
|
typedef int (anim_function_t)(struct anim_data *data, int init);
|
|
|
|
anim_function_t anim_player_idle;
|
|
anim_function_t anim_player_walking;
|
|
|
|
anim_function_t anim_tile_start;
|
|
anim_function_t anim_tile_end;
|
|
anim_function_t anim_door_closed;
|
|
anim_function_t anim_door_opening;
|
|
anim_function_t anim_door_open;
|
|
anim_function_t anim_door_closing;
|
|
|
|
/* struct anim_frame: Subrectangle of an animation sheet */
|
|
struct anim_frame
|
|
{
|
|
bopti_image_t *source;
|
|
int left, top;
|
|
int w, h;
|
|
};
|
|
|
|
/* struct anim_data: Data for currently-running animations */
|
|
struct anim_data
|
|
{
|
|
/* Animation update function */
|
|
anim_function_t *function;
|
|
/* Frame to draw */
|
|
struct anim_frame img;
|
|
/* On-screen entity displacement */
|
|
int dx, dy;
|
|
/* Animation direction */
|
|
int dir;
|
|
/* Current frame */
|
|
int frame;
|
|
/* Duration left until next frame; updated by the engine. Animation
|
|
function is called when it becomes negative or null */
|
|
int duration;
|
|
};
|
|
|
|
/* Draw an animation frame */
|
|
void dframe(int x, int y, struct anim_frame const frame);
|
|
|
|
#endif /* _MYSTNB_ANIMATION_H */
|