Mercurial > molko
comparison libmlk-rpg/rpg/tileset.h @ 298:196264679079
misc: remove usage of bool
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Mar 2021 18:49:08 +0100 |
parents | 08ab73b32832 |
children | d01e83210ca2 |
comparison
equal
deleted
inserted
replaced
297:6151152d009c | 298:196264679079 |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #ifndef MOLKO_RPG_TILESET_H | 19 #ifndef MOLKO_RPG_TILESET_H |
20 #define MOLKO_RPG_TILESET_H | 20 #define MOLKO_RPG_TILESET_H |
21 | 21 |
22 #include <stdbool.h> | |
23 #include <stddef.h> | 22 #include <stddef.h> |
24 | 23 |
25 #include <core/core.h> | 24 #include <core/core.h> |
26 | 25 |
27 struct sprite; | 26 struct sprite; |
28 | 27 |
29 /** | |
30 * \brief Describe a tile property in a tileset. | |
31 * | |
32 * It can contains an animation and a collision mask. | |
33 */ | |
34 struct tileset_tiledef { | 28 struct tileset_tiledef { |
35 unsigned short id; /*!< (+) Tile index. */ | 29 unsigned short id; |
36 short x; /*!< (+) Collision region starts in y. */ | 30 short x; |
37 short y; /*!< (+) Collision region starts in y. */ | 31 short y; |
38 unsigned short w; /*!< (+) Collision width. */ | 32 unsigned short w; |
39 unsigned short h; /*!< (+) Collision height. */ | 33 unsigned short h; |
40 }; | 34 }; |
41 | 35 |
42 /** | |
43 * \brief Per tile animation. | |
44 * | |
45 * This structure is used to animate tiles by id. Create one for every tile | |
46 * that must be animated. | |
47 */ | |
48 struct tileset_animation { | 36 struct tileset_animation { |
49 unsigned short id; /*!< (*) Tile index. */ | 37 unsigned short id; |
50 struct animation *animation; /*!< (+&?) Animation. */ | 38 struct animation *animation; |
51 }; | 39 }; |
52 | 40 |
53 /** | |
54 * \brief Tileset definition. | |
55 */ | |
56 struct tileset { | 41 struct tileset { |
57 struct tileset_tiledef *tiledefs; /*!< (+&?) Per tile properties (must be sorted by id). */ | 42 struct tileset_tiledef *tiledefs; |
58 size_t tiledefsz; /*!< (+) Number of tile properties. */ | 43 size_t tiledefsz; |
59 struct tileset_animation *anims; /*!< (+&?) Per tile animations (must be sorted by id). */ | 44 struct tileset_animation *anims; |
60 size_t animsz; /*!< (+) Number of tile animations. */ | 45 size_t animsz; |
61 struct sprite *sprite; /*!< (+&) Sprite to generate the terrain. */ | 46 struct sprite *sprite; |
62 }; | 47 }; |
63 | 48 |
64 CORE_BEGIN_DECLS | 49 CORE_BEGIN_DECLS |
65 | 50 |
66 /** | 51 int |
67 * Tells if the tileset is correctly initialized. | 52 tileset_ok(const struct tileset *); |
68 * | |
69 * \param ts the tileset to check (maybe NULL) | |
70 * \return True if correctly initialized. | |
71 */ | |
72 bool | |
73 tileset_ok(const struct tileset *ts); | |
74 | 53 |
75 /** | |
76 * Prepare the tileset before use. | |
77 * | |
78 * You must call this function once before using it in the rendering of the map | |
79 * because it will prepare animations. | |
80 * | |
81 * \pre ts != NULL | |
82 * \param ts the tileset to prepare | |
83 */ | |
84 void | 54 void |
85 tileset_start(struct tileset *ts); | 55 tileset_start(struct tileset *); |
86 | 56 |
87 /** | |
88 * Update tileset. | |
89 * | |
90 * This function will update tileset animations. It is not necessary to call it | |
91 * if the tileset does not contain any animation. | |
92 * | |
93 * \pre ts != NULL | |
94 * \param ts the tileset to update | |
95 * \param ticks the elapsed milliseconds since last frame | |
96 */ | |
97 void | 57 void |
98 tileset_update(struct tileset *ts, unsigned int ticks); | 58 tileset_update(struct tileset *, unsigned int); |
99 | 59 |
100 /** | |
101 * Draw a tileset cell at the given position. | |
102 * | |
103 * If the tileset at the given row, column is animated its animation will be | |
104 * rendered otherwise it uses the sprite row column. | |
105 * | |
106 * The argument r and c must not be out of bounds. | |
107 * | |
108 * \pre ts != NULL | |
109 * \param ts the tileset to use | |
110 * \param r the row number | |
111 * \param c the column number | |
112 * \param x the x coordinate | |
113 * \param y the y coordinate | |
114 */ | |
115 void | 60 void |
116 tileset_draw(const struct tileset *ts, unsigned int r, unsigned int c, int x, int y); | 61 tileset_draw(const struct tileset *, unsigned int, unsigned int, int, int); |
117 | 62 |
118 CORE_END_DECLS | 63 CORE_END_DECLS |
119 | 64 |
120 #endif /* !MOLKO_RPG_TILESET_H */ | 65 #endif /* !MOLKO_RPG_TILESET_H */ |