comparison librpg/rpg/tileset.h @ 229:e71039d820a7

doc: improve documentation
author David Demelier <markand@malikania.fr>
date Thu, 19 Nov 2020 16:46:26 +0100
parents 71f989ae8de9
children
comparison
equal deleted inserted replaced
228:2734223d3daf 229:e71039d820a7
35 short y; /*!< (+) Collision region starts in y. */ 35 short y; /*!< (+) Collision region starts in y. */
36 unsigned short w; /*!< (+) Collision width. */ 36 unsigned short w; /*!< (+) Collision width. */
37 unsigned short h; /*!< (+) Collision height. */ 37 unsigned short h; /*!< (+) Collision height. */
38 }; 38 };
39 39
40 /**
41 * \brief Per tile animation.
42 *
43 * This structure is used to animate tiles by id. Create one for every tile
44 * that must be animated.
45 */
40 struct tileset_animation { 46 struct tileset_animation {
41 unsigned short id; /* (*) Tile index. */ 47 unsigned short id; /*!< (*) Tile index. */
42 struct animation *animation; /* (+&?) Animation. */ 48 struct animation *animation; /*!< (+&?) Animation. */
43 }; 49 };
44 50
45 /** 51 /**
46 * \brief Tileset definition. 52 * \brief Tileset definition.
47 */ 53 */
51 struct tileset_animation *anims; /*!< (+&?) Per tile animations (must be sorted by id). */ 57 struct tileset_animation *anims; /*!< (+&?) Per tile animations (must be sorted by id). */
52 size_t animsz; /*!< (+) Number of tile animations. */ 58 size_t animsz; /*!< (+) Number of tile animations. */
53 struct sprite *sprite; /*!< (+&) Sprite to generate the terrain. */ 59 struct sprite *sprite; /*!< (+&) Sprite to generate the terrain. */
54 }; 60 };
55 61
62 /**
63 * Tells if the tileset is correctly initialized.
64 *
65 * \param ts the tileset to check (maybe NULL)
66 * \return True if correctly initialized.
67 */
56 bool 68 bool
57 tileset_ok(const struct tileset *ts); 69 tileset_ok(const struct tileset *ts);
58 70
71 /**
72 * Prepare the tileset before use.
73 *
74 * You must call this function once before using it in the rendering of the map
75 * because it will prepare animations.
76 *
77 * \pre ts != NULL
78 * \param ts the tileset to prepare
79 */
59 void 80 void
60 tileset_start(struct tileset *ts); 81 tileset_start(struct tileset *ts);
61 82
83 /**
84 * Update tileset.
85 *
86 * This function will update tileset animations. It is not necessary to call it
87 * if the tileset does not contain any animation.
88 *
89 * \pre ts != NULL
90 * \param ts the tileset to update
91 * \param ticks the elapsed milliseconds since last frame
92 */
62 void 93 void
63 tileset_update(struct tileset *ts, unsigned int ticks); 94 tileset_update(struct tileset *ts, unsigned int ticks);
64 95
96 /**
97 * Draw a tileset cell at the given position.
98 *
99 * If the tileset at the given row, column is animated its animation will be
100 * rendered otherwise it uses the sprite row column.
101 *
102 * The argument r and c must not be out of bounds.
103 *
104 * \pre ts != NULL
105 * \param ts the tileset to use
106 * \param r the row number
107 * \param c the column number
108 * \param x the x coordinate
109 * \param y the y coordinate
110 */
65 void 111 void
66 tileset_draw(const struct tileset *ts, unsigned int r, unsigned int c, int x, int y); 112 tileset_draw(const struct tileset *ts, unsigned int r, unsigned int c, int x, int y);
67 113
68 #endif /* !MOLKO_RPG_TILESET_H */ 114 #endif /* !MOLKO_RPG_TILESET_H */