diff 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
line wrap: on
line diff
--- a/librpg/rpg/tileset.h	Thu Nov 19 14:11:11 2020 +0100
+++ b/librpg/rpg/tileset.h	Thu Nov 19 16:46:26 2020 +0100
@@ -37,9 +37,15 @@
 	unsigned short h;                       /*!< (+) Collision height. */
 };
 
+/**
+ * \brief Per tile animation.
+ *
+ * This structure is used to animate tiles by id. Create one for every tile
+ * that must be animated.
+ */
 struct tileset_animation {
-	unsigned short id;                      /* (*) Tile index. */
-	struct animation *animation;            /* (+&?) Animation. */
+	unsigned short id;                      /*!< (*) Tile index. */
+	struct animation *animation;            /*!< (+&?) Animation. */
 };
 
 /**
@@ -53,15 +59,55 @@
 	struct sprite *sprite;                  /*!< (+&) Sprite to generate the terrain. */
 };
 
+/**
+ * Tells if the tileset is correctly initialized.
+ *
+ * \param ts the tileset to check (maybe NULL)
+ * \return True if correctly initialized.
+ */
 bool
 tileset_ok(const struct tileset *ts);
 
+/**
+ * Prepare the tileset before use.
+ *
+ * You must call this function once before using it in the rendering of the map
+ * because it will prepare animations.
+ *
+ * \pre ts != NULL
+ * \param ts the tileset to prepare
+ */
 void
 tileset_start(struct tileset *ts);
 
+/**
+ * Update tileset.
+ *
+ * This function will update tileset animations. It is not necessary to call it
+ * if the tileset does not contain any animation.
+ *
+ * \pre ts != NULL
+ * \param ts the tileset to update
+ * \param ticks the elapsed milliseconds since last frame
+ */
 void
 tileset_update(struct tileset *ts, unsigned int ticks);
 
+/**
+ * Draw a tileset cell at the given position.
+ *
+ * If the tileset at the given row, column is animated its animation will be
+ * rendered otherwise it uses the sprite row column.
+ *
+ * The argument r and c must not be out of bounds.
+ *
+ * \pre ts != NULL
+ * \param ts the tileset to use
+ * \param r the row number
+ * \param c the column number
+ * \param x the x coordinate
+ * \param y the y coordinate
+ */
 void
 tileset_draw(const struct tileset *ts, unsigned int r, unsigned int c, int x, int y);