diff --git a/assets/bg.si2 b/assets/game_background.si2 similarity index 100% rename from assets/bg.si2 rename to assets/game_background.si2 diff --git a/assets/logo.si2 b/assets/logo.si2 new file mode 100644 index 0000000..54bfef7 Binary files /dev/null and b/assets/logo.si2 differ diff --git a/assets/menu_background.si2 b/assets/menu_background.si2 new file mode 100644 index 0000000..763c1c7 Binary files /dev/null and b/assets/menu_background.si2 differ diff --git a/headers/pixelManager.h b/headers/pixelManager.h index 1bd3350..f890972 100644 --- a/headers/pixelManager.h +++ b/headers/pixelManager.h @@ -25,11 +25,13 @@ public: * 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 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 logo{"assets/logo.si2"}; + nsGui::Sprite gameBackground{"assets/game_background.si2"}; + nsGui::Sprite menuBackground{"assets/menu_background.si2"}; nsGui::Sprite rightHand{"assets/hand_open.si2"}; nsGui::Sprite leftHand{MIRROR(rightHand)}; @@ -49,7 +51,8 @@ public: // 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 drawGameBackground() const; + void drawMenuBackground() const; void drawFPS(unsigned fps) const; diff --git a/src/drawEntity.cpp b/src/drawEntity.cpp index fe0638d..25ea2a7 100644 --- a/src/drawEntity.cpp +++ b/src/drawEntity.cpp @@ -76,8 +76,12 @@ void PixelManager::drawSprite(const Sprite& sprite, const Position& pos) const { sprite.draw(window); } -void PixelManager::drawBackground() const { - background.draw(window); +void PixelManager::drawGameBackground() const { + gameBackground.draw(window); +} + +void PixelManager::drawMenuBackground() const { + menuBackground.draw(window); } unsigned PixelManager::getScreenHeight() const { diff --git a/src/drawMenu.cpp b/src/drawMenu.cpp index 168658e..9cfa1e4 100644 --- a/src/drawMenu.cpp +++ b/src/drawMenu.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include "pixelManager.h" #include "utils.h" @@ -15,6 +17,8 @@ void PixelManager::displayButton(const Position& baseVector,const string& text,n void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){ startFrame(); + drawMenuBackground(); + drawSprite(logo,Position(100,50)); size_t margin = 0; size_t cpt = 0; for(string& value : currentMenu.entries ){ @@ -26,22 +30,25 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){ } PlayMode PixelManager::showInitialMenu(){ - //return PlayMode::SINGLE; // will remove vector entries {"single player","multi player (local)","EXIT"}; Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite}; + const unsigned xOffset = getScreenHeight() / 2; + const unsigned yOffset = getScreenWidth() / 2; + chrono::milliseconds waitTime = chrono::milliseconds(100); while(true){ - displayMenu(Position(100,100),initial); - // dessends + displayMenu(Position(350,0),initial); + // go down if (window.isPressed({'s', false})){ ++initial.currentValue; if (initial.currentValue > initial.entries.size()) initial.currentValue = 0; + this_thread::sleep_for(waitTime); } - // monte - if (window.isPressed({'z', false})) + // go up + if (window.isPressed({'z', false})){ if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1; else --initial.currentValue; - - + this_thread::sleep_for(waitTime); + } else if (window.isPressed({13, false})){ switch(initial.currentValue){ case 0: diff --git a/src/game/display.cpp b/src/game/display.cpp index 80c7f82..001b02a 100644 --- a/src/game/display.cpp +++ b/src/game/display.cpp @@ -5,7 +5,7 @@ * The more important stuff must be drawn last */ void Game::displayAll(unsigned fps) const { - pm.drawBackground(); + pm.drawGameBackground(); for (unsigned i = 0; i < this->grid.size(); ++i){ for (unsigned j = 0; j < this->grid[i].size(); ++j){ Position vec(