Adoranda/include/animation.h

45 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#include <gint/display.h>
2021-08-15 03:46:49 +02:00
struct AnimData;
2021-08-15 03:46:49 +02:00
typedef int (anim_function_t)(struct AnimData *data, int init);
2021-08-05 03:12:40 +02:00
anim_function_t anim_player_walking;
2021-12-23 19:21:27 +01:00
anim_function_t anim_player_sprinting;
anim_function_t anim_player_idle;
2021-08-15 03:46:49 +02:00
struct AnimFrame
{
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;
};
2021-08-15 03:46:49 +02:00
struct AnimData
{
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*/
2021-08-15 03:46:49 +02:00
struct AnimFrame 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;
};
2021-08-15 03:10:05 +02:00
/*draw the frame*/
2021-08-15 03:46:49 +02:00
void dframe(int x, int y, struct AnimFrame const frame);
2021-08-15 03:10:05 +02:00
/*animation for player walking*/
2021-08-15 03:46:49 +02:00
int anim_player_walking(struct AnimData *data, int init);
2021-12-23 19:21:27 +01:00
/*animation for player sprinting*/
int anim_player_sprinting(struct AnimData *data, int init);
2021-08-15 03:10:05 +02:00
/*animation for player doing nothing*/
2021-08-15 03:46:49 +02:00
int anim_player_idle(struct AnimData *data, int init);