SuperSpaceInvaderTurboApoca.../headers/pixelManager.h

247 lines
4.4 KiB
C++

/*!
*
* @file pixelManager.h
* @author RUBINI Thomas
* @author SIMAILA Djalim
* @author FABRE Lucas
* @date January 2022
* @version 1.0
* @brief manager
*
*/
#ifndef GUARD_PIXELMANAGER_H
#define GUARD_PIXELMANAGER_H
#include <string>
#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"
using namespace std;
#define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize()
/*!
* @class PixelManager
* @brief main display function, clear the window and calls sub display functions
*/
class PixelManager{
public:
MinGL& window;
/*
* Sprites are not const because for some reason the texture is associated with coordinates,
* and we have no way to dissociate them...
* So the objects are constantly updated with new coordinates as they need to be drawn
* We used {} insead of () for the constructor because the () makes the compiler think we declare methods
*
* (We could copy them every time, but I feel like copying image data every frame isn't great)
*/
/*!
* @brief
*/
nsGui::Sprite logo{"assets/logo.si2"};
/*!
* @brief
*/
nsGui::Sprite gameBackground{"assets/game_background.si2"};
/*!
* @brief
*/
nsGui::Sprite menuBackground{"assets/menu_background.si2"};
/*!
* @brief
*/
nsGui::Sprite rightHand{"assets/hand_open.si2"};
/*!
* @brief
*/
nsGui::Sprite leftHand{MIRROR(rightHand)};
/*!
* @brief
* @param[]
* @fn
*/
explicit PixelManager(MinGL&);
/*!
* @brief
* @param[in] baseVector :
* @param[in] size :
* @param[in] color :
* @fn
*/
void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
/*!
* @brief
* @param[in] baseVector :
* @param[in] size :
* @param[in] color :
* @fn
*/
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
/*!
* @brief
* @param[in] baseVector
* @param[in] size
* @param[in] color
* @fn
*/
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
#define HEART_LENGTH 40
/*!
* @brief
* @param[]
* @fn
*/
void drawHeart(const Position& baseVector) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
/*!
* @brief
* @param[]
* @fn
*/
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
/*!
* @brief
* @param[]
* @fn
*/
void displayMenu(const Position& pos, Menu& currentMenu);
/*!
* @brief
* @param[]
* @fn
*/
void drawGameBackground() const;
/*!
* @brief
* @param[]
* @fn
*/
void drawMenuBackground() const;
// TODO remove because unused ?
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawFPS(unsigned fps) const;
PlayMode showInitialMenu();
PlayMode showDeathMenu();
unsigned getScreenHeight() const;
unsigned getScreenWidth() const;
/*!
* @brief
* @param[]
* @fn
*/
void startFrame() const;
/*!
* @brief
* @param[]
* @fn
*/
void endFrame() const;
/*!
* @brief
* @param[]
* @fn
*/
void askPlayerNameMenu(playerID pID, string& name) const;
// y will be negative sometimes, so not unsigned
/*!
* @brief
* @param[]
* @fn
*/
void drawGodBench(int y) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawGodRightHand(const Position& pos) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawGodLeftHand(const Position& pos) const;
/*!
* @brief
* @param[]
* @fn
*/
void drawGodFace(int y, bool angry=false) const;
private:
// Explanation for choices :
// non reference output : I don't think we have another choice than a std::move() here
vector<RGBAcolor> mirrorData(const vector<RGBAcolor>& inPixels, unsigned rowSize);
};
#endif