diff --git a/Pontu/include/model/Bridge.h b/Pontu/include/model/Bridge.h index 0e20c9e..a4374a6 100644 --- a/Pontu/include/model/Bridge.h +++ b/Pontu/include/model/Bridge.h @@ -1,7 +1,7 @@ /** * \file Bridge.h * \brief Bridge - * \autor Martin Roualt, Jacques Thomas + * \autor Martin Rouault, Jacques Thomas * \date 13/12/2021 */ diff --git a/Pontu/include/model/Coord.h b/Pontu/include/model/Coord.h index e889449..c41afbd 100644 --- a/Pontu/include/model/Coord.h +++ b/Pontu/include/model/Coord.h @@ -10,14 +10,40 @@ #include +/** + * \struct Coord + * \brief From (0,0) to (8,8), represent a global coordinates in a board + */ typedef struct { int x; ///< Coordinate on the X-axis int y; ///< Coordinate on the Y-axis } Coord; - +/** + * \brief Create a new Coord (x,y) + * + * \param [in] x + * \param [in] y + * \return new Coord + */ Coord newCoord(const int x, const int y); -bool coordValide(const Coord coord); + +/** + * \brief Test if a coord is valide (ie x and y between 0 and 8) + * + * \param [in] coord The coord to test + * \return true if coord is valid, false otherwise + */ +bool coordValid(const Coord coord); + + +/** + * \brief test if two coord are equal + * + * \param [in] a One coord + * \param [in] b One other coord + * \return true if (a.x==b.x and a.y==b.y), false otherwise + */ bool coordEqual(const Coord a, const Coord b); #endif //COORD_INCLUDED diff --git a/Pontu/src/engine/InputProcessor.c b/Pontu/src/engine/InputProcessor.c index 1a859a2..d8ca015 100644 --- a/Pontu/src/engine/InputProcessor.c +++ b/Pontu/src/engine/InputProcessor.c @@ -38,7 +38,7 @@ InputElement proccessInput(InputProcessor *inputProcessor, const SDL_Rect* board const SDL_Point mousePoint = {.x = event.button.x, .y = event.button.y}; if (SDL_PointInRect(&mousePoint, boardRect)) { - if (coordValide(inputProcessor->selectedCase)) + if (coordValid(inputProcessor->selectedCase)) { Coord newCoord = screenCoordToGameCoord(&mousePoint, boardRect); if (coordEqual(inputProcessor->selectedCase, newCoord)) { diff --git a/Pontu/src/model/Coord.c b/Pontu/src/model/Coord.c index f8e4911..3bacee9 100644 --- a/Pontu/src/model/Coord.c +++ b/Pontu/src/model/Coord.c @@ -5,9 +5,10 @@ Coord newCoord(const int x, const int y) { return c; } -bool coordValide(const Coord coord) +bool coordValid(const Coord coord) { - return coord.x >= 0 && coord.y >= 0; + return coord.x >= 0 && coord.y >= 0 + && coord.x < 9 && coord.y < 9; } bool coordEqual(const Coord a, const Coord b)