SANDAL2
A SDL2 Wrapper in C
Sprite.h
Go to the documentation of this file.
1 #ifndef SPRITE_SANDAL2_KLEVH
2 #define SPRITE_SANDAL2_KLEVH
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdlib.h>
9 
20 typedef struct Sprite{
21  struct Sprite * next;
23  struct Sprite * prev;
25  int coords[4];
27  unsigned lifespan;
29  int code;
31 }Sprite;
32 
37 typedef struct ListSprite{
42  unsigned size;
44  int side;
46  unsigned wasChanged;
48  int code;
50  struct ListSprite * next;
52  struct ListSprite * prev;
54 }ListSprite;
55 
60 typedef struct{
65  unsigned size;
68 
69 /* -----------------------------------------------------
70  * ListSprite
71  */
81 void freeListSprite(ListSprite * l);
93 int addSprite(ListSprite * l,int x,int y,int width,int height,unsigned lifespan,int code);
100 int delSprite(ListSprite * l,int code);
108 int setLifeSpanSprite(ListSprite * l,int code,unsigned lifespan);
115 int setSprite(ListSprite * l,int code);
116 /* ----------------------------------------------------- */
117 
118 /* -----------------------------------------------------
119  * ListAnimation
120  */
144 int delAnimation(ListAnimation *l,int code);
157 int addSpriteAnimation(ListAnimation *l,int code,int x,int y,int width,int height,unsigned lifespan,int codeS);
165 int delSpriteAnimation(ListAnimation *l,int code,int codeS);
174 int setLifeSpanSpriteAnimation(ListAnimation *l,int code,int codeS,unsigned lifespan);
181 int setAnimation(ListAnimation *l,int code);
188 int setSpriteAnimation(ListAnimation *l,int codeS);
189 /* ----------------------------------------------------- */
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif
int setLifeSpanSpriteAnimation(ListAnimation *l, int code, int codeS, unsigned lifespan)
set the lifespan of a sprite
Definition: Sprite.c:296
struct ListSprite * next
Definition: Sprite.h:50
informations about a step of an animation
Definition: Sprite.h:20
unsigned size
Definition: Sprite.h:42
int setSpriteAnimation(ListAnimation *l, int codeS)
change the current sprite in the current list of sprite in a given list of animation ...
Definition: Sprite.c:335
int code
Definition: Sprite.h:29
int createAnimation(ListAnimation *l, int code)
add an empty animation to the list
Definition: Sprite.c:190
int setLifeSpanSprite(ListSprite *l, int code, unsigned lifespan)
set the lifespan of a sprite
Definition: Sprite.c:117
int coords[4]
Definition: Sprite.h:25
int delAnimation(ListAnimation *l, int code)
remove an empty animation from the list
Definition: Sprite.c:224
int addSprite(ListSprite *l, int x, int y, int width, int height, unsigned lifespan, int code)
add a Sprite to the list
Definition: Sprite.c:38
int setAnimation(ListAnimation *l, int code)
set the current animation of a list of animations
Definition: Sprite.c:315
struct Sprite * next
Definition: Sprite.h:21
ListSprite * first
Definition: Sprite.h:61
struct ListSprite * prev
Definition: Sprite.h:52
int addSpriteAnimation(ListAnimation *l, int code, int x, int y, int width, int height, unsigned lifespan, int codeS)
add a Sprite to an animation
Definition: Sprite.c:258
unsigned size
Definition: Sprite.h:65
int code
Definition: Sprite.h:48
int side
Definition: Sprite.h:44
unsigned wasChanged
Definition: Sprite.h:46
int delSpriteAnimation(ListAnimation *l, int code, int codeS)
remove a Sprite to an animation
Definition: Sprite.c:277
Sprite * current
Definition: Sprite.h:40
all steps of an animation
Definition: Sprite.h:37
ListSprite * current
Definition: Sprite.h:63
int delSprite(ListSprite *l, int code)
remove a Sprite to the list
Definition: Sprite.c:79
void freeListAnimation(ListAnimation *l)
free the memory of a list of animation
Definition: Sprite.c:174
ListAnimation * initListAnimation()
create an empty list of animation
Definition: Sprite.c:162
void freeListSprite(ListSprite *l)
free the memory of a list of sprite
Definition: Sprite.c:23
unsigned lifespan
Definition: Sprite.h:27
ListSprite * initListSprite(int code)
create an empty list of sprite
Definition: Sprite.c:6
struct Sprite * prev
Definition: Sprite.h:23
int setSprite(ListSprite *l, int code)
change the current sprite in a given list of sprite
Definition: Sprite.c:137
a list of animations
Definition: Sprite.h:60
Sprite * first
Definition: Sprite.h:38