Project

General

Profile

Statistics
| Revision:

root / proj / libs / graph / include / sprite.h @ 342

History | View | Annotate | Download (2.28 KB)

1 331 up20180642
#ifndef SPRITE_H_INCLUDED
2
#define SPRITE_H_INCLUDED
3
4
/**
5
 * @defgroup sprite_t sprite_t
6
 * @ingroup graph
7
 * @brief Sprite module.
8
 *
9
 * A sprite allows to draw a basic_sprite_t, while also providing some transformations for that basic_sprite_t.
10
 *
11
 * @{
12
 */
13
14 332 up20180642
#include "basic_sprite.h"
15
16 331 up20180642
typedef struct sprite sprite_t;
17
18 333 up20180642
/**
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
 */
23 331 up20180642
sprite_t* (sprite_ctor)(const basic_sprite_t *bsp);
24 333 up20180642
/**
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.
31 331 up20180642
 * @param   p   Pointer to sprite_t to be destructed
32
 */
33
void      (sprite_dtor)(sprite_t *p);
34 333 up20180642
/**
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
 */
40 331 up20180642
void (sprite_set_pos)   (sprite_t *p, int16_t x, int16_t y);
41 333 up20180642
/**
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
 */
49 331 up20180642
void (sprite_set_angle) (sprite_t *p, double angle);
50 333 up20180642
/**
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
 */
57 331 up20180642
void (sprite_set_scale) (sprite_t *p, double scale);
58 333 up20180642
/**
59
 * @brief Get sprite angle.
60
 * @param   p   Pointer to sprite
61
 * @return      Sprite angle
62
 */
63 331 up20180642
double   (sprite_get_angle)(const sprite_t *p);
64 333 up20180642
/**
65
 * @brief   Get sprite width (same as the underlying basic sprite).
66
 * @param   p   Pointer to sprite
67
 * @return      Sprite width
68
 */
69 331 up20180642
uint16_t (sprite_get_w)(const sprite_t *p);
70 333 up20180642
/**
71
 * @brief   Get sprite height (same as the underlying basic sprite).
72
 * @param   p   Pointer to sprite
73
 * @return      Sprite height
74
 */
75 331 up20180642
uint16_t (sprite_get_h)(const sprite_t *p);
76 333 up20180642
/**
77
 * @brief Draw sprite in buffer.
78
 * @param   p   Pointer to sprite
79
 */
80 331 up20180642
void (sprite_draw)(const sprite_t *p);
81
82
/**
83
 * @}
84
 */
85
86
#endif //SPRITE_H_INCLUDED