1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #ifndef __ANIMATION_H__
# define __ANIMATION_H__
#include <SDL/SDL.h>
typedef struct
{
SDL_Surface *image;
Uint16 delay;
} animation_frame;
typedef struct
{
Uint16 nbr_of_frames;
animation_frame *frames;
} animation;
typedef struct
{
const animation *anim;
enum { STOP, PLAY } status;
Uint16 current_frame;
Uint16 counter;
} animator;
typedef struct s_jeu
{
char letsexit;
int nb_explo;
/* L'animation et les tableaux contenant les animators ainsi que leurs positions */
animation *anim;
animator *player;
SDL_Rect *pos;
SDL_Surface *screen;
} t_jeu;
void animation_frame_init(animation_frame * frame, SDL_Surface * image, Uint16 delay);
void animation_frame_cleanup(animation_frame * frame);
void animation_frame_draw(animation_frame * frame, SDL_Surface * dst, SDL_Rect * pos);
void animation_init(animation * anim, Uint16 nbr_of_frames);
void animation_setframe(animation * anim, Uint16 pos, SDL_Surface * surface, Uint16 delay);
void animation_cleanup(animation * anim);
void animator_init(animator *player, animation *anim);
void animator_play(animator * ator);
void animator_stop(animator * ator);
void animator_rewind(animator * ator);
void animator_nextframe(animator * ator);
void animator_update(animator * ator);
void animator_draw(animator * ator, SDL_Surface * dest, SDL_Rect * pos);
#endif /* !__ANIMATION_H__ */ |