Revision 333
more changes, added docs
sprite.h | ||
---|---|---|
13 | 13 |
|
14 | 14 |
#include "basic_sprite.h" |
15 | 15 |
|
16 |
struct sprite; |
|
17 | 16 |
typedef struct sprite sprite_t; |
18 | 17 |
|
18 |
/** |
|
19 |
* @brief Construct sprite. |
|
20 |
* @param bsp Basic sprite from which to build the sprite |
|
21 |
* @return Pointer to constructed sprite, or NULL if failed |
|
22 |
*/ |
|
19 | 23 |
sprite_t* (sprite_ctor)(const basic_sprite_t *bsp); |
20 |
/* |
|
21 |
* /!\ WARNING: Entity destructor does not destruct the basic_sprite passed as |
|
22 |
* constructor arguments, since it is assumed the same basic_sprite may be used to |
|
23 |
* draw several sprites. It is thus YOUR responsibility to delete basic_sprite's. |
|
24 |
/** |
|
25 |
* @brief Destruct sprite. |
|
26 |
* |
|
27 |
* |
|
28 |
* @attention Destructor does not destruct the basic sprite passed as |
|
29 |
* constructor argument, since it is assumed the same basic sprite may be used to |
|
30 |
* draw several sprites. It is thus YOUR responsibility to delete basic sprites. |
|
24 | 31 |
* @param p Pointer to sprite_t to be destructed |
25 | 32 |
*/ |
26 | 33 |
void (sprite_dtor)(sprite_t *p); |
27 |
|
|
34 |
/** |
|
35 |
* @brief Set sprite position. |
|
36 |
* @param p Pointer to sprite |
|
37 |
* @param x X-position in map |
|
38 |
* @param y Y-position in map |
|
39 |
*/ |
|
28 | 40 |
void (sprite_set_pos) (sprite_t *p, int16_t x, int16_t y); |
29 |
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0); |
|
41 |
/** |
|
42 |
* @brief Set sprite angle. |
|
43 |
* |
|
44 |
* If not provided, will be drawn with angle 0, corresponding to the same |
|
45 |
* orientation as the original image. |
|
46 |
* @param p Pointer to sprite |
|
47 |
* @param angle Angle in radians, counterclockwise positive and 0 on positive x-axis |
|
48 |
*/ |
|
30 | 49 |
void (sprite_set_angle) (sprite_t *p, double angle); |
50 |
/** |
|
51 |
* @brief Set sprite scale. |
|
52 |
* |
|
53 |
* Default scale is 1, corresponding to original image scale. |
|
54 |
* @param p Pointer to sprite |
|
55 |
* @param scale Scale, greater than 0 |
|
56 |
*/ |
|
31 | 57 |
void (sprite_set_scale) (sprite_t *p, double scale); |
32 |
|
|
33 |
int16_t (sprite_get_x)(const sprite_t *p); |
|
34 |
int16_t (sprite_get_y)(const sprite_t *p); |
|
58 |
/** |
|
59 |
* @brief Get sprite angle. |
|
60 |
* @param p Pointer to sprite |
|
61 |
* @return Sprite angle |
|
62 |
*/ |
|
35 | 63 |
double (sprite_get_angle)(const sprite_t *p); |
64 |
/** |
|
65 |
* @brief Get sprite width (same as the underlying basic sprite). |
|
66 |
* @param p Pointer to sprite |
|
67 |
* @return Sprite width |
|
68 |
*/ |
|
36 | 69 |
uint16_t (sprite_get_w)(const sprite_t *p); |
70 |
/** |
|
71 |
* @brief Get sprite height (same as the underlying basic sprite). |
|
72 |
* @param p Pointer to sprite |
|
73 |
* @return Sprite height |
|
74 |
*/ |
|
37 | 75 |
uint16_t (sprite_get_h)(const sprite_t *p); |
38 |
|
|
76 |
/** |
|
77 |
* @brief Draw sprite in buffer. |
|
78 |
* @param p Pointer to sprite |
|
79 |
*/ |
|
39 | 80 |
void (sprite_draw)(const sprite_t *p); |
40 | 81 |
|
41 | 82 |
/** |
Also available in: Unified diff