diff --git a/GAME/include/map.h b/GAME/include/map.h index eb8462151c2e50e029931c32c40499faa7b18796..557e3d64b03a905bb89fd89fb1ac0b3f49dea83c 100644 --- a/GAME/include/map.h +++ b/GAME/include/map.h @@ -2,18 +2,34 @@ // Created by Tiny on 2/16/2021. */ +/*! + * \file map.h + * \brief Map Header File + * \authors Tin + * \version 1 + * \date 16/02/2021 + * + * Map structure and functions definiton. + * + */ + #ifndef INSAGAME_MAP_H #define INSAGAME_MAP_H +/*! + * \struct MAP + * \brief Map structure + */ + typedef struct { - char *path; //path of image bmp of map - int width; - int height; - int **functional; //2D functional matrix + char *path; /**< Path of image bmp of map */ + int width; /**< Map's width */ + int height; /**< Map's height */ + int **functional; /**< 2D functional matrix */ } MAP; -int initmap(MAP *map,char *path); //allocate the map's name and call the maptomatrix -int **maptomatrix(MAP *map); //get matrix'length and width => create a functional matrix from the bmp matrix +int initmap(MAP *map,char *path); +int **maptomatrix(MAP *map); diff --git a/GAME/src/map.c b/GAME/src/map.c index 067396ea081c0d5f7571696e14d10e94972bc9d1..6e9dc47d67f4502fbe11cd5fcf8a108c470c6950 100644 --- a/GAME/src/map.c +++ b/GAME/src/map.c @@ -2,11 +2,32 @@ // Created by Tiny on 2/16/2021. */ +/*! + * \file map.c + * \brief Map Source File + * \authors Tin + * \version 1 + * \date 16/02/2021 + * + * Map function implementation. + * + */ + #include "map.h" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> + +/*! + * \fn int initmap(MAP *map,char *path) + * \brief This function initialize the map : allocate the map's name and call the maptomatrix + * + * \param [in] map the map pointer + * \param [in] path the map image path + * \return 0 if the initialization went right. + */ + int initmap(MAP *map,char *path){ int lenpath = strlen(path); //get the path lenght map->path = (char *)malloc((lenpath)*sizeof(char)); //allocate the path @@ -15,6 +36,13 @@ int initmap(MAP *map,char *path){ return 0; } +/*! + * \fn int **maptomatrix(MAP *map) + * \brief This function gets the matrix's length and width and creates a functional matrix from the bmp matrix. + * + * \param [in] map the map pointer + * \return NULL if there is an error when opening the map, fonc otherwise. + */ int **maptomatrix(MAP *map){