Skip to content
Snippets Groups Projects
Commit fc1c20fd authored by llebasca's avatar llebasca
Browse files

Doxygen updates on src and personnage.h

parent 7a0047f8
No related branches found
No related tags found
4 merge requests!8Modele,!7Modele,!6Modele,!5Modele Version 1
...@@ -41,14 +41,14 @@ typedef struct { ...@@ -41,14 +41,14 @@ typedef struct {
}Personnage; }Personnage;
void init_pers(Personnage * character, int x, int y, int length, int width, int speed, char * path); 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 //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 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 testboundscol(Personnage * pers); int test_bounds_col(Personnage * pers);
int testprofcol(Personnage * pers, Prof * prof); int test_prof_col(Personnage * pers, Prof * prof);
int testmapcol(Personnage * pers, MAP * map, DS * exam); int test_map_col(Personnage * pers, MAP * map, DS * exam);
int testpointwithprof(int x, int y, Prof *prof); int test_point_with_prof(int x, int y, Prof *prof);
#endif /*GAME_INSA_PROJECT_PERSONNAGE_H*/ #endif /*GAME_INSA_PROJECT_PERSONNAGE_H*/
...@@ -22,12 +22,11 @@ ...@@ -22,12 +22,11 @@
/*! /*!
* \fn int init_DS(DS * exam, int door_DS, char * path) * \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] exam a DS pointer
* \param [in] door_DS a door number corresponding to the DS location * \param [in] door_DS a door number corresponding to the DS location
* \param [in] path the DS image path * \param [in] path the DS image path
* \return 1 if the initialization went right.
*/ */
void init_DS(DS * exam, int door_DS, char * path){ void init_DS(DS * exam, int door_DS, char * path){
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* *
* \param [in] map the map pointer * \param [in] map the map pointer
* \param [in] path the map image path * \param [in] path the map image path
* \return 0 if the initialization went right.
*/ */
void initmap(MAP *map,char *func_path, char *vis_path){ void initmap(MAP *map,char *func_path, char *vis_path){
...@@ -46,7 +45,7 @@ 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. * \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 * \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){ int **maptomatrix(MAP *map){
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/*! /*!
* \fn int init_pers(Personnage * character, int x, int y, int length, int width, int speed, char * path) * \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] character a pointer on the character
* \param [in] x the character's abscissa * \param [in] x the character's abscissa
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
* \param [in] width the character's width * \param [in] width the character's width
* \param [in] speed the character's speed * \param [in] speed the character's speed
* \param [in] path the path to the character's image * \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){ 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 ...@@ -48,7 +47,14 @@ void init_pers(Personnage * character, int x, int y, int length, int width, int
strcpy(character->image_pers, path); 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 //calculate 3 others points of rectangle
character->x_hr = character->x_pers + character->larg_pers ; character->x_hr = character->x_pers + character->larg_pers ;
character->y_hr = character->y_pers; character->y_hr = character->y_pers;
...@@ -60,10 +66,21 @@ void calculpointspers(Personnage * character){ ...@@ -60,10 +66,21 @@ void calculpointspers(Personnage * character){
//Collisions Functions //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 //test variables
int testbounds = testboundscol(pers); ; int testbounds = test_bounds_col(pers); ;
int testprof = testprofcol(pers,prof); int testprof = test_prof_col(pers,prof);
//test bounds collision //test bounds collision
...@@ -75,18 +92,34 @@ int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){ ...@@ -75,18 +92,34 @@ int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){
//return the map test position //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)) { 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 1;
} }
return 0; 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 testhl;
int testhr; int testhr;
...@@ -114,8 +147,17 @@ int testprofcol(Personnage * pers, Prof * prof){ ...@@ -114,8 +147,17 @@ int testprofcol(Personnage * pers, Prof * prof){
return 0; 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 (( x > prof->x_prof) && (x<prof->x_prof+prof->larg_prof)) {
if (( y > prof->y_prof) && (y < prof->y_prof + prof->long_prof)) { if (( y > prof->y_prof) && (y < prof->y_prof + prof->long_prof)) {
return 1; return 1;
...@@ -124,13 +166,21 @@ int testpointwithprof(int x, int y, Prof *prof){ ...@@ -124,13 +166,21 @@ int testpointwithprof(int x, int y, Prof *prof){
return 0; 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 test_map_col(Personnage * pers, MAP * map, DS * exam ){
int testmapcol(Personnage * pers, MAP * map, DS * exam ){ int testhl = test_point_with_map(pers->x_pers,pers->y_pers,map,exam);
int testhl = testpointwithmap(pers->x_pers,pers->y_pers,map,exam); int testhr = test_point_with_map(pers->x_hr,pers->y_hr,map,exam) ;
int testhr = testpointwithmap(pers->x_hr,pers->y_hr,map,exam) ; int testll = test_point_with_map(pers->x_ll,pers->y_ll,map,exam) ;
int testll = testpointwithmap(pers->x_ll,pers->y_ll,map,exam) ; int testlr = test_point_with_map(pers->x_lr,pers->y_lr,map,exam) ;
int testlr = testpointwithmap(pers->x_lr,pers->y_lr,map,exam) ;
if(testhl==2 || testhr==2 || testll==2 || testlr==2) { if(testhl==2 || testhr==2 || testll==2 || testlr==2) {
return 2; return 2;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
/*! /*!
* \fn int init_prof(Prof * prof, int x, int y, int length, int width, int speed, char * path) * \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] Teacher a pointer on the character
* \param [in] x the Teacher's abscissa * \param [in] x the Teacher's abscissa
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
* \param [in] width the Teacher's width * \param [in] width the Teacher's width
* \param [in] speed the Teacher's speed * \param [in] speed the Teacher's speed
* \param [in] path the path to the Teacher's image * \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){ void init_prof(Prof * prof, int x, int y, int length, int width, int speed, char * path){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment