From fc1c20fd9dd0425aa44eb1445aa31db708966fdc Mon Sep 17 00:00:00 2001 From: llebasca <llebasca@insa-rennes.fr> Date: Fri, 12 Mar 2021 15:15:52 +0100 Subject: [PATCH] Doxygen updates on src and personnage.h --- GAME/include/personnage.h | 12 +++--- GAME/src/DS.c | 3 +- GAME/src/map.c | 3 +- GAME/src/personnage.c | 82 +++++++++++++++++++++++++++++++-------- GAME/src/prof.c | 3 +- 5 files changed, 75 insertions(+), 28 deletions(-) diff --git a/GAME/include/personnage.h b/GAME/include/personnage.h index 039e89b..beb1532 100644 --- a/GAME/include/personnage.h +++ b/GAME/include/personnage.h @@ -41,14 +41,14 @@ typedef struct { }Personnage; void init_pers(Personnage * character, int x, int y, int length, int width, int speed, char * path); -void calculpointspers(Personnage * character); +void calcul_points_pers(Personnage * character); //Collisions Functions -int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map); // return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds -int testboundscol(Personnage * pers); -int testprofcol(Personnage * pers, Prof * prof); -int testmapcol(Personnage * pers, MAP * map, DS * exam); -int testpointwithprof(int x, int y, Prof *prof); +int test_position(Personnage * pers, Prof * prof, DS * exam, MAP * map); // return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds +int test_bounds_col(Personnage * pers); +int test_prof_col(Personnage * pers, Prof * prof); +int test_map_col(Personnage * pers, MAP * map, DS * exam); +int test_point_with_prof(int x, int y, Prof *prof); #endif /*GAME_INSA_PROJECT_PERSONNAGE_H*/ diff --git a/GAME/src/DS.c b/GAME/src/DS.c index 098c735..feb89e9 100644 --- a/GAME/src/DS.c +++ b/GAME/src/DS.c @@ -22,12 +22,11 @@ /*! * \fn int init_DS(DS * exam, int door_DS, char * path) - * \brief This function initialize a DS : position (the door number) and the path to the DS's image. + * \brief This function initializes a DS : position (the door number) and the path to the DS's image. * * \param [in] exam a DS pointer * \param [in] door_DS a door number corresponding to the DS location * \param [in] path the DS image path - * \return 1 if the initialization went right. */ void init_DS(DS * exam, int door_DS, char * path){ diff --git a/GAME/src/map.c b/GAME/src/map.c index 22b2d28..2ddee1a 100644 --- a/GAME/src/map.c +++ b/GAME/src/map.c @@ -25,7 +25,6 @@ * * \param [in] map the map pointer * \param [in] path the map image path - * \return 0 if the initialization went right. */ void initmap(MAP *map,char *func_path, char *vis_path){ @@ -46,7 +45,7 @@ void initmap(MAP *map,char *func_path, char *vis_path){ * \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. + * \return NULL if there is an error when opening the map, fonc value otherwise. */ int **maptomatrix(MAP *map){ diff --git a/GAME/src/personnage.c b/GAME/src/personnage.c index 037c719..292bcd7 100644 --- a/GAME/src/personnage.c +++ b/GAME/src/personnage.c @@ -26,7 +26,7 @@ /*! * \fn int init_pers(Personnage * character, int x, int y, int length, int width, int speed, char * path) - * \brief This function initialize the character : position of the character's top left corner (x,y), size (length, width), speed and also the path to the character's image. + * \brief This function initializes the character : position of the character's top left corner (x,y), size (length, width), speed and also the path to the character's image. * * \param [in] character a pointer on the character * \param [in] x the character's abscissa @@ -35,7 +35,6 @@ * \param [in] width the character's width * \param [in] speed the character's speed * \param [in] path the path to the character's image - * \return 1 if the initialization went right. */ void init_pers(Personnage * character, int x, int y, int length, int width, int speed, char * path){ @@ -48,7 +47,14 @@ void init_pers(Personnage * character, int x, int y, int length, int width, int strcpy(character->image_pers, path); } -void calculpointspers(Personnage * character){ +/*! + * \fn void calcul_points_pers(Personnage * character) + * \brief This function calculates the position of the 3 other character's corners. + * + * \param [in] character a pointer on the character + */ + +void calcul_points_pers(Personnage * character){ //calculate 3 others points of rectangle character->x_hr = character->x_pers + character->larg_pers ; character->y_hr = character->y_pers; @@ -60,10 +66,21 @@ void calculpointspers(Personnage * character){ //Collisions Functions -int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){ +/*! + * \fn int test_position(Personnage * pers, Prof * prof, DS * exam, MAP * map) + * \brief This function calculates if the there is a collision between the character and anything else. + * + * \param [in] pers a pointer on the character + * \param [in] prof a pointer on the teacher + * \param [in] exam a pointer on the exam + * \param [in] map a pointer on the map + * \return 0 if there is nothing, 1 if there's a wall, 2 if it's an exam, 3 if it's a teacher, 4 if the character is trying to to out the window. + */ + +int test_position(Personnage * pers, Prof * prof, DS * exam, MAP * map){ //test variables - int testbounds = testboundscol(pers); ; - int testprof = testprofcol(pers,prof); + int testbounds = test_bounds_col(pers); ; + int testprof = test_prof_col(pers,prof); //test bounds collision @@ -75,18 +92,34 @@ int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){ //return the map test position - return testmapcol(pers,map,exam); // = 0 if nothing , 1 if wall, 2 if exam + return test_map_col(pers,map,exam); // = 0 if nothing , 1 if wall, 2 if exam } +/*! + * \fn int test_bounds_col(Personnage * pers) + * \brief This function calculates if the character is trying to go out the window. + * + * \param [in] pers a pointer on the character + * \return 1 if the character is trying to go out the window, 0 otherwise. + */ -int testboundscol(Personnage * pers){ +int test_bounds_col(Personnage * pers){ if((pers->x_pers <= 0) || (pers->y_pers <= 0) || (pers->x_pers >= WINDOW_WIDTH - pers->larg_pers) || (pers->y_pers >= WINDOW_HEIGHT - pers->long_pers)) { return 1; } return 0; } -int testprofcol(Personnage * pers, Prof * prof){ +/*! + * \fn int test_prof_col(Personnage * pers, Prof * prof) + * \brief This function calculates if the character is in collision with the teacher. + * + * \param [in] pers a pointer on the character + * \param [in] prof a pointer on the teacher + * \return 1 if there is a collision, 0 otherwise. + */ + +int test_prof_col(Personnage * pers, Prof * prof){ int testhl; int testhr; @@ -114,8 +147,17 @@ int testprofcol(Personnage * pers, Prof * prof){ return 0; } +/*! + * \fn int test_point_with_prof(int x, int y, Prof *prof) + * \brief This function tests if one of the character's corner is in collision with the teacher. + * + * \param [in] x one of the character's abscissa (one of the 4 corners) + * \param [in] y the ordinate corresponding to the same corner + * \param [in] prof a pointer on the teacher + * \return 1 if there is a collision, 0 otherwise. + */ -int testpointwithprof(int x, int y, Prof *prof){ +int test_point_with_prof(int x, int y, Prof *prof){ if (( x > prof->x_prof) && (x<prof->x_prof+prof->larg_prof)) { if (( y > prof->y_prof) && (y < prof->y_prof + prof->long_prof)) { return 1; @@ -124,13 +166,21 @@ int testpointwithprof(int x, int y, Prof *prof){ return 0; } +/*! + * \fn int test_map_col(Personnage * pers, MAP * map, DS * exam ) + * \brief This function tests if the character is in collision with the teacher. + * + * \param [in] pers a pointer on the character + * \param [in] map a pointer on the map + * \param [in] exam a pointer on an exam + * \return 2 if it's an exam, 1 if there's a wall, 0 otherwise. + */ - -int testmapcol(Personnage * pers, MAP * map, DS * exam ){ - int testhl = testpointwithmap(pers->x_pers,pers->y_pers,map,exam); - int testhr = testpointwithmap(pers->x_hr,pers->y_hr,map,exam) ; - int testll = testpointwithmap(pers->x_ll,pers->y_ll,map,exam) ; - int testlr = testpointwithmap(pers->x_lr,pers->y_lr,map,exam) ; +int test_map_col(Personnage * pers, MAP * map, DS * exam ){ + int testhl = test_point_with_map(pers->x_pers,pers->y_pers,map,exam); + int testhr = test_point_with_map(pers->x_hr,pers->y_hr,map,exam) ; + int testll = test_point_with_map(pers->x_ll,pers->y_ll,map,exam) ; + int testlr = test_point_with_map(pers->x_lr,pers->y_lr,map,exam) ; if(testhl==2 || testhr==2 || testll==2 || testlr==2) { return 2; diff --git a/GAME/src/prof.c b/GAME/src/prof.c index d133996..7b5527b 100644 --- a/GAME/src/prof.c +++ b/GAME/src/prof.c @@ -25,7 +25,7 @@ /*! * \fn int init_prof(Prof * prof, int x, int y, int length, int width, int speed, char * path) - * \brief This function initialize the Teacher : position of the Teacher's top left corner (x,y), size (length, width), speed and also the path to the Teacher's image. + * \brief This function initializes the Teacher : position of the Teacher's top left corner (x,y), size (length, width), speed and also the path to the Teacher's image. * * \param [in] Teacher a pointer on the character * \param [in] x the Teacher's abscissa @@ -34,7 +34,6 @@ * \param [in] width the Teacher's width * \param [in] speed the Teacher's speed * \param [in] path the path to the Teacher's image - * \return 1 if the initialization went right. */ void init_prof(Prof * prof, int x, int y, int length, int width, int speed, char * path){ -- GitLab