Adoranda/include/animation.h

38 lines
904 B
C
Raw Normal View History

#pragma once
#include <gint/display.h>
struct anim_data;
typedef int (anim_function_t)(struct anim_data *data, int init);
2021-08-05 03:12:40 +02:00
anim_function_t anim_player_walking;
anim_function_t anim_player_idle;
struct anim_frame
{
2021-08-08 01:43:26 +02:00
/*the image*/
bopti_image_t *source;
2021-08-08 01:43:26 +02:00
/*the left and top pixels to know where to start drawing*/
int left, top;
2021-08-08 01:43:26 +02:00
/*the width and height of one frame*/
int w, h;
};
struct anim_data
{
2021-08-08 01:43:26 +02:00
/*the function to call to update the frame*/
anim_function_t *function;
2021-08-08 01:43:26 +02:00
/*the anim frame*/
struct anim_frame img;
2021-08-08 01:43:26 +02:00
/*if the animation needs to move*/
int dx, dy;
2021-08-08 01:43:26 +02:00
/*the direction*/
int dir;
2021-08-08 01:43:26 +02:00
/*the current frame*/
int frame;
2021-08-08 01:43:26 +02:00
/*the duration of one frame*/
int duration;
};
void dframe(int x, int y, struct anim_frame const frame);
2021-08-05 03:12:40 +02:00
int anim_player_walking(struct anim_data *data, int init);
int anim_player_idle(struct anim_data *data, int init);