From a1b3cf4ae4a7b8e1e0be8843664e2b8e24930971 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 11 Jan 2022 20:41:20 +0100 Subject: [PATCH] some more doc --- headers/errors.h | 2 +- headers/goodPixelManager.h | 2 +- headers/mySprite.h | 10 + headers/pixelManager/goodPixelManager.h | 90 -------- headers/pixelManager/pixelManager.h | 273 ------------------------ src/errors.cpp | 10 + src/goodPixelManager.cpp | 10 + src/mySprite.cpp | 10 + src/pixelManager.cpp | 13 ++ src/utils.cpp | 10 + 10 files changed, 65 insertions(+), 365 deletions(-) delete mode 100644 headers/pixelManager/goodPixelManager.h delete mode 100644 headers/pixelManager/pixelManager.h diff --git a/headers/errors.h b/headers/errors.h index 7806f85..b94151c 100644 --- a/headers/errors.h +++ b/headers/errors.h @@ -4,7 +4,7 @@ * @author RUBINI Thomas * @date January 2022 * @version 1.0 - * @brief Configuration file data storage + * @brief error handling * */ diff --git a/headers/goodPixelManager.h b/headers/goodPixelManager.h index e27087e..596ddeb 100644 --- a/headers/goodPixelManager.h +++ b/headers/goodPixelManager.h @@ -4,7 +4,7 @@ * @author RUBINI Thomas * @date January 2022 * @version 1.0 - * @brief Manages screen display with async sprite loading + * @brief Second screen display method * */ diff --git a/headers/mySprite.h b/headers/mySprite.h index b2a67a1..d809c45 100644 --- a/headers/mySprite.h +++ b/headers/mySprite.h @@ -1,3 +1,13 @@ +/*! + * + * @file mySprite.h + * @author RUBINI Thomas + * @date January 2022 + * @version 1.0 + * @brief Custom sprite implementation (needed for async load) + * + */ + #ifndef GUARD_MYSPRITE_H #define GUARD_MYSPRITE_H diff --git a/headers/pixelManager/goodPixelManager.h b/headers/pixelManager/goodPixelManager.h deleted file mode 100644 index e27087e..0000000 --- a/headers/pixelManager/goodPixelManager.h +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * - * @file goodPixelManager.h - * @author RUBINI Thomas - * @date January 2022 - * @version 1.0 - * @brief Manages screen display with async sprite loading - * - */ - - -#ifndef GUARD_GOODPIXELMANAGER_H -#define GUARD_GOODPIXELMANAGER_H - -#include "pixelManager.h" - - -/*! - * @class GoodPixelManager - * @brief Extension of the PixelManager class, which override - * the draw methods to use sprites instead of shapes - */ -class GoodPixelManager : public PixelManager{ - - /*! - * @brief loads sprites in parallel using multiple threads - * @param[out] tasks : vectot of task - * @fn void loadSprites(); - */ - void loadSprites(vector& tasks) override; - - /*! - * @brief sprite of the first player - */ - MySprite player1; - - /*! - * @brief sprite of the second player - */ - MySprite player2; - - /*! - * @brief sprite of the type A invader - */ - MySprite invaderA; - - /*! - * @brief sprite of the type B invader - */ - MySprite invaderB; - - /*! - * @brief sprite of the type B invader - */ - MySprite invaderC; - - /*! - * @brief sprite of the missile - */ - MySprite missile; - - /*! - * @brief sprite of the torpedo - */ - MySprite torpedo; - - /*! - * @brief sprite of the heart - */ - MySprite heart; - - void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const override; - void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const override; - void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const override; - void drawPlayer(playerID pID, unsigned x, unsigned width, const RGBAcolor& color) const override; - void drawMissile(const Position& baseVector, unsigned width, const RGBAcolor& color) const override; - void drawTorpedo(const Position& baseVector, unsigned width, const RGBAcolor& color) const override; - void drawHeart(const Position& baseVector) const override; -public: - - /*! - * @brief constructor the pixel manager class - * @param[in] window : window of the pixel manager - * @fn GoodPixelManager(MinGL&); - */ - explicit GoodPixelManager(MinGL& window); -}; - - -#endif diff --git a/headers/pixelManager/pixelManager.h b/headers/pixelManager/pixelManager.h deleted file mode 100644 index 11e7748..0000000 --- a/headers/pixelManager/pixelManager.h +++ /dev/null @@ -1,273 +0,0 @@ -/*! - * - * @file pixelManager.h - * @author RUBINI Thomas - * @author SIMAILA Djalim - * @author FABRE Lucas - * @date January 2022 - * @version 1.0 - * @brief Manages screen display - * - */ - -#ifndef GUARD_PIXELMANAGER_H -#define GUARD_PIXELMANAGER_H - -#include -#include "mingl/mingl.h" -#include "mingl/shape/line.h" -#include "mingl/shape/triangle.h" -#include "mingl/shape/rectangle.h" -#include "mingl/shape/circle.h" -#include "mingl/gui/sprite.h" -#include "mingl/gui/text.h" -#include "utils.h" -#include "playMode.h" -#include "menu.h" -#include "scoresManager.h" -#include "mySprite.h" - -using namespace std; - -typedef nsGui::GlutFont::GlutFonts Font; - -/*! -* @class PixelManager -* @brief main display function, clear the window and calls sub display functions -*/ - -/* - * It's MinGL's fault. This is all I have to say - */ - -#define ADD_SPRITE_TASK(X) tasks.push_back((X).asyncLoad("assets/"#X".si2")); - -class PixelManager{ -public: - - /*! - * @brief display window - */ - MinGL& window; - - /*! - * @brief loads sprites in parallel using multiple threads - * @param[in] tasks : vectot of task - * @fn void loadSprites(); - */ - virtual void loadSprites(vector& tasks); - - /*! - * @brief sprite of the logo of the game - */ - MySprite logo; - - /*! - * @brief sprite of the background during menu - */ - MySprite menuBackground; - - /*! - * @brief sprite of the background during gameplay - */ - MySprite gameBackground; - - /*! - * @brief sprite of the right hand of god - */ - MySprite rightHand; - - /*! - * @brief sprite of the left hand of god - */ - MySprite leftHand; - - /*! - * @brief constructor the pixel manager class - * @param[in] window : window of the pixel manager - * @fn PixelManager(MinGL&); - */ - explicit PixelManager(MinGL& window); - - /*! - * @brief display a type A invader on screen - * @param[in] baseVector : pixel coordinate of the invader - * @param[in] size : size multiplicator of the invader - * @param[in] color : color multiplicaror of the invader - * @fn void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - */ - virtual void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - - /*! - * @brief display a type B invader on screen - * @param[in] baseVector : pixel coordinate of the invader - * @param[in] size : size multiplicator of the invader - * @param[in] color : color multiplicaror of the invader - * @fn void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - */ - virtual void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - - /*! - * @brief display a type C invader on screen - * @param[in] baseVector : pixel coordinate of the invader - * @param[in] size : size multiplicator of the invader - * @param[in] color : color multiplicaror of the invader - * @fn void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - */ - virtual void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const; - - /*! - * @brief display a player on screen - * @param[in] pID : the ID of the player to draw - * @param[in] x : horizontal position of the player - * @param[in] witdh : width of the player - * @param[in] color : color of the plater - * @fn void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const; - */ - virtual void drawPlayer(playerID pID, unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const; - - /*! - * @brief display a missile on screen - * @param[in] baseVector : pixel coordinates of the missile - * @param[in] width : width of the missle - * @param[in] color : color of the missile - * @fn void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; - */ - virtual void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; - - /*! - * @brief display a torpedo on screen - * @param[in] baseVector : pixel coordinates of the torpedo - * @param[in] width : width of the torpedo - * @param[in] color : color of the torpedo - * @fn void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; - */ - virtual void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; - -#define HEART_LENGTH 64 - - /*! - * @brief display a singular heart on screen - * @param[in] baseVector : pixel coordinates of the heart - * @fn void drawHeart(const Position& baseVector) const; - */ - virtual void drawHeart(const Position& baseVector) const; - - /*! - * @brief display a sprite on screen - * @param[in] msp : sprite to draw - * @param[in] pos : pixel coordinates to draw the sprite - * @fn void drawSprite(const MySprite& msp, const Position& pos = Position(0, 0)) const; - */ - void drawSprite(const MySprite& msp, const Position& pos) const; - - /*! - * @brief display a menu button on screen - * @param[in] baseVector : pixel coordinates of the button - * @param[in] text : text inside the button - * @param[in] color : color of the text inside the button - * @fn void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color); - */ - void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color); - - /*! - * @brief display text on screen - * @param[in] pos : pixel coordinates of the text - * @param[in] text : text to show on screen - * @param[in] color : color of the text to show - * @param[in] font : the glut font to use for the text - * @fn void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const; - */ - void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const; - - /*! - * @brief show the title screen of the game - * @return the playmode chosen inside the menu - * @fn PlayMode showInitialMenu(); - */ - PlayMode showInitialMenu(); - - /*! - * @brief show the menu after a player lose, or all invader has been defeated - * @return true if the player plays again, else false - * @param[in] rankings : the current top 5 score - * @param[in] winner : the winner of the game - * @fn bool showDeathMenu(); - */ - bool showDeathMenu(const vector& rankings,const WinValue& winner); - - /*! - * @brief give the height of the screen - * @return the height of the screen in pixel - * @fn unsigned getScreenHeight() const; - */ - unsigned getScreenHeight() const; - - /*! - * @brief give the width of the screen - * @return the width of the screen in pixel - * @fn unsigned getScreenWidth() const; - */ - unsigned getScreenWidth() const; - - /*! - * @brief clear the screen for a new frame - * @fn void startFrame() const; - */ - void startFrame() const; - - /*! - * @brief finish a frame render - * @fn void endFrame() const; - */ - void endFrame() const; - - /*! - * @brief display the player name selection menu - * @param[in] pID : player id - * @param[in] score : score of this player - * @param[out] name : name selected by the player - * @fn void askPlayerNameMenu(playerID pID, unsigned score, string& name); - */ - void askPlayerNameMenu(playerID pID, unsigned score, string& name); - - // y will be negative sometimes, so not unsigned - - /*! - * @brief display god's bar - * @param[in] y : god y pixel position - * @fn void drawGodBench(int y) const - */ - void drawGodBench(int y) const; - - /*! - * @brief display god's face - * @param[in] y : god's face y pixel position - * @param[in] angry : flag if god is angry or not - * @fn void drawGodFace(int y, bool angry=false) const; - */ - void drawGodFace(int y, bool angry=false) const; - -private: - - /*! - * @brief display a menu on screen - * @param[in] pos : pixel coordinates of the menu - * @param[in,out] currentMenu : menu struct conteining the menu option - * @fn void drawMenu(const Position& pos, Menu& currentMenu); - */ - void drawMenu(const Position& pos, Menu& currentMenu); - - /*! - * @brief display a menu on screen - * @param[in] pos : pixel coordinates of the menu - * @param[in,out] currentMenu : menu struct conteining the menu option - * @param[in] rankings : the current top 10 players - * @param[in] winner : the winner of the game - * @fn void drawMenu(const Position& pos, Menu& currentMenu); - */ - void drawMenu(const Position& pos, Menu& currentMenu, const vector& rankings, const WinValue& winner); -}; - - -#endif \ No newline at end of file diff --git a/src/errors.cpp b/src/errors.cpp index d266781..a415a42 100644 --- a/src/errors.cpp +++ b/src/errors.cpp @@ -1,3 +1,13 @@ +/*! + * + * @file configData.h + * @author RUBINI Thomas + * @date January 2022 + * @version 1.0 + * @brief error handling + * + */ + #include "errors.h" config_error::config_error(const string& msg) : runtime_error(msg) { diff --git a/src/goodPixelManager.cpp b/src/goodPixelManager.cpp index fae26f6..bc4a584 100644 --- a/src/goodPixelManager.cpp +++ b/src/goodPixelManager.cpp @@ -1,3 +1,13 @@ +/*! + * + * @file goodPixelManager.cpp + * @author RUBINI Thomas + * @date January 2022 + * @version 1.0 + * @brief implementation of the second screen display method + * + */ + #include "goodPixelManager.h" void GoodPixelManager::loadSprites(vector& tasks) { diff --git a/src/mySprite.cpp b/src/mySprite.cpp index 614f26e..be610a3 100644 --- a/src/mySprite.cpp +++ b/src/mySprite.cpp @@ -1,3 +1,13 @@ +/*! + * + * @file mySprite.cpp + * @author RUBINI Thomas + * @date January 2022 + * @version 1.0 + * @brief Custom sprite implementation (needed for async load) + * + */ + #include "utils.h" #include "mySprite.h" diff --git a/src/pixelManager.cpp b/src/pixelManager.cpp index 432e86a..343dc24 100644 --- a/src/pixelManager.cpp +++ b/src/pixelManager.cpp @@ -1,3 +1,16 @@ +/*! + * + * @file pixelManager.cpp + * @author RUBINI Thomas + * @author SIMAILA Djalim + * @author FABRE Lucas + * @date January 2022 + * @version 1.0 + * @brief Manages screen display + * + */ + + #include "pixelManager.h" diff --git a/src/utils.cpp b/src/utils.cpp index 2b1b41a..1c222e3 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,3 +1,13 @@ +/*! + * + * @file utils.cpp + * @author RUBINI Thomas + * @date January 2022 + * @version 1.0 + * @brief utility for the game + * + */ + #include "utils.h" bool areLinesColliding(unsigned start1, unsigned end1, unsigned start2, unsigned end2){