diff librpg/rpg/map.h @ 210:70e6ed74940d

rpg: attempt of collide detection in map
author David Demelier <markand@malikania.fr>
date Sat, 14 Nov 2020 16:59:11 +0100
parents 852d0b7817ce
children adcbb7ccfdee
line wrap: on
line diff
--- a/librpg/rpg/map.h	Wed Nov 11 17:10:40 2020 +0100
+++ b/librpg/rpg/map.h	Sat Nov 14 16:59:11 2020 +0100
@@ -24,6 +24,8 @@
  * \brief Game map.
  */
 
+#include <stddef.h>
+
 #include <core/texture.h>
 
 #include "walksprite.h"
@@ -44,12 +46,29 @@
 };
 
 /**
+ * \brief Describe a tile in a tileset.
+ */
+struct map_tile {
+	short id;                       /*!< (*) Tile index. */
+	short x;                        /*!< (*) Collision region starts in y. */
+	short y;                        /*!< (*) Collision region starts in y. */
+	unsigned short w;               /*!< (*) Collision width. */
+	unsigned short h;               /*!< (*) Collision height. */
+};
+
+/**
  * \brief Map layer.
  */
 struct map_layer {
 	unsigned short *tiles;          /*!< (+&) Array of tiles, depending on the map size. */
 };
 
+enum map_flags {
+	MAP_FLAGS_NONE          = 0,            /*!< No flags. */
+	MAP_FLAGS_SHOW_GRID     = (1 << 0),     /*!< Show grid pattern. */
+	MAP_FLAGS_SHOW_COLLIDE  = (1 << 2)      /*!< Show collision layer. */
+};
+
 /**
  * \brief Map object.
  *
@@ -71,6 +90,11 @@
 	unsigned short tile_h;          /*!< (-) Pixels per cell (height). */
 	struct sprite *tileset;         /*!< (+&) Tileset to use. */
 	struct texture picture;         /*!< (-) Map drawn into a texture. */
+	struct map_tile *tiles;         /*!< (+&?) Per tile properties (must be sorted). */
+	size_t tilesz;                  /*!< (+) Number of tile properties. */
+
+	/* View options. */
+	enum map_flags flags;           /*!< (+) View options. */
 
 	/* Player. */
 	struct sprite *player_sprite;   /*!< (+) The sprite to use */