Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.31 KB)

1
#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
#include "basic_sprite.h"
15

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

    
84
/**
85
 * @}
86
 */
87

    
88
#endif //SPRITE_H_INCLUDED