1 /*
2  * GNUjump
3  * =======
4  *
5  * Copyright (C) 2005-2008, Juan Pedro Bolivar Puente
6  *
7  * GNUjump is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * GNUjump is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _SPRITE_H_
22 #define _SPRITE_H_
23 
24 #include "surface.h"
25 
26 
27 /*
28 ** Determines a position relative to whatever matter.
29 */
30 typedef struct position
31 {
32   int x;
33   int y;
34 } L_position;
35 
36 typedef struct sprite_data
37 {
38   JPB_surface **pic;
39   float *time;
40   Uint8 sides;
41   int nFrames;
42 } L_spriteData;
43 
44 typedef struct sprite_data_rot
45 {
46   JPB_surfaceRot **pic;
47   float *time;
48   Uint8 sides;
49   int nFrames;
50 } L_spriteDataRot;
51 
52 typedef struct sprite_control
53 {
54   L_spriteData *sdata;
55   float elpTime;
56   int frame;
57 } L_spriteCtl;
58 
59 typedef struct sprite_control_rot
60 {
61   L_spriteDataRot *sdata;
62   float elpTime;
63   int frame;
64 } L_spriteCtlRot;
65 
66 L_spriteDataRot *loadSpriteDataRot (char *filename, int sides, char *path);
67 L_spriteData *loadSpriteData (char *filename, int sides, char *path);
68 int animateSprite (L_spriteCtl * sprite, float dt);
69 int animateSpriteRot (L_spriteCtlRot * sprite, float dt);
70 void printSprite (L_spriteCtl * sprite, SDL_Rect * src_r, SDL_Rect * dest_r,
71 		  int side);
72 void printSpriteRot (L_spriteCtlRot * sprite, SDL_Rect * src_r,
73 		     SDL_Rect * dest_r, int side, float angle);
74 void freeSpriteData (L_spriteData * sprite);
75 void freeSpriteDataRot (L_spriteDataRot * sprite);
76 JPB_surfaceRot *getFrameRot (L_spriteCtlRot * sprite, int side);
77 void initializeSpriteCtlRot (L_spriteCtlRot * sprite, L_spriteDataRot * data);
78 void initializeSpriteCtl (L_spriteCtl * sprite, L_spriteData * data);
79 
80 #endif //_SPRITE_H_
81