#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" using namespace std; #define MIRROR(SP) mirrorData((SP).getPixelData(), (SP).getRowSize()), (SP).getRowSize() 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) */ nsGui::Sprite background{"assets/bg.si2"}; nsGui::Sprite rightHand{"assets/hand_open.si2"}; nsGui::Sprite leftHand{MIRROR(rightHand)}; explicit PixelManager(MinGL&); void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const; void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const; void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const; void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const; void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const; #define HEART_LENGTH 40 void drawHeart(const Position& baseVector) const; void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const; void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color); // TODO remove because unused ? void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const; void displayMenu(const Position& pos, Menu& currentMenu); void drawBackground() const; void drawFPS(unsigned fps) const; PlayMode showInitialMenu(); bool showDeathMenu() const; unsigned getScreenHeight() const; unsigned getScreenWidth() const; void startFrame() const; void endFrame() const; void askPlayerNameMenu(playerID pID, string& name) const; // y will be negative sometimes, so not unsigned void drawGodBench(int y) const; void drawGodRightHand(const Position& pos) const; void drawGodLeftHand(const Position& pos) const; 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 mirrorData(const vector& inPixels, unsigned rowSize); }; #endif