From: malak585 Date: Mon, 4 Dec 2023 11:06:24 +0000 (+0100) Subject: Done with every menu - Alma, Lukas, Malin X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=fc166e3367298232ab385635156502466bce3463;p=TDDC76_proj.git Done with every menu - Alma, Lukas, Malin --- diff --git a/assets/highscore.csv b/assets/highscore.csv index 65d19a7..65b2d03 100644 Binary files a/assets/highscore.csv and b/assets/highscore.csv differ diff --git a/assets/muspekareGul.png b/assets/muspekareGul.png index 1f22c8b..25551c1 100644 Binary files a/assets/muspekareGul.png and b/assets/muspekareGul.png differ diff --git a/src/GameOver_menu.cc b/src/GameOver_menu.cc index 99cda26..c19186c 100644 --- a/src/GameOver_menu.cc +++ b/src/GameOver_menu.cc @@ -13,7 +13,7 @@ using json = nlohmann::json; -GameOver_menu::GameOver_menu(int const points, json& params) : texture{}, texture2{}, sprite{}, rectangle{}, mouse_l{}, mouse_r{}, linetext{}, entertext{}, pointstext{}, +GameOver_menu::GameOver_menu(int const points, json& params) : texture{}, texture2{}, sprite{}, rectangle{}, mouse_l{}, mouse_r{}, linetext{}, funfacttext{}, entertext{}, pointstext{}, playerInput{}, data{}, playerText{}, savetext{}, quittext{}, font{}, exit_game{false}, menu{false}, menu_index{1}, points{points} { texture.loadFromFile("assets/game_over.png"); @@ -45,6 +45,12 @@ GameOver_menu::GameOver_menu(int const points, json& params) : texture{}, textur pointstext.setPosition (S_WIDTH / 2 , ((S_HEIGHT / 2) - 100)); pointstext.setFillColor(sf::Color::Black); + // Fun fact + funfacttext = sf::Text{"You can buy: " + std::to_string(static_cast(points)/static_cast(79)) + " Kir!", font, 14 }; + sf::FloatRect gbff {funfacttext.getGlobalBounds()}; + funfacttext.setOrigin(gbff.width / 2, gbff.height / 2); + funfacttext.setPosition (S_WIDTH / 2 , ((S_HEIGHT / 2) - 70)); + funfacttext.setFillColor(sf::Color::Black); // Enter text entertext = sf::Text{ "Enter your name:", font, 24 }; @@ -75,8 +81,7 @@ GameOver_menu::GameOver_menu(int const points, json& params) : texture{}, textur texture2.loadFromFile("assets/muspekareRed.png"); mouse_l.setTexture(texture2); - mouse_l.setScale(0.1, 0.1); - mouse_l.setRotation(180); + mouse_l.setScale(-0.1, 0.1); sf::FloatRect gbm {mouse_l.getGlobalBounds()}; mouse_r.setTexture(texture2); @@ -118,7 +123,7 @@ void GameOver_menu::update(Context& context) // mouse placement mouse_r.setPosition(((S_WIDTH / 2) + 60 - 30*(menu_index - 1)), ((S_HEIGHT / 2) + 85 + 50*(menu_index - 1))); - mouse_l.setPosition(((S_WIDTH / 2) - 58 + 30*(menu_index - 1)), ((S_HEIGHT / 2) + 132 + 50*(menu_index - 1))); + mouse_l.setPosition(((S_WIDTH / 2) - 58 + 30*(menu_index - 1)), ((S_HEIGHT / 2) + 85 + 50*(menu_index - 1))); } @@ -130,9 +135,10 @@ void GameOver_menu::render(sf::RenderWindow& window) const window.draw(mouse_l); window.draw(mouse_r); - window.draw(entertext); window.draw(playerText); window.draw(linetext); + window.draw(funfacttext); + window.draw(entertext); window.draw(pointstext); window.draw(savetext); window.draw(quittext); @@ -220,7 +226,7 @@ void GameOver_menu::handle_input(sf::Event& event) } // if not backspace, print letters - else if(playerInput.getSize() < 30) + else if(playerInput.getSize() < 15) { playerInput += event.text.unicode; } diff --git a/src/Pause_menu.cc b/src/Pause_menu.cc index 8cfb4a6..95e1cb8 100644 --- a/src/Pause_menu.cc +++ b/src/Pause_menu.cc @@ -22,8 +22,7 @@ Pause_menu::Pause_menu() : texture{}, texture2{}, sprite{}, mouse_l{}, mouse_r{} texture2.loadFromFile("assets/muspekareGul.png"); mouse_l.setTexture(texture2); - mouse_l.setScale(0.1, 0.1); - mouse_l.setRotation(180); + mouse_l.setScale(-0.1, 0.1); sf::FloatRect gbm {mouse_l.getGlobalBounds()}; mouse_r.setTexture(texture2); @@ -71,26 +70,26 @@ void Pause_menu::update(Context& context) // changes color on text depending on selection if( menu_index == 1) { - resumetext.setFillColor(sf::Color::Yellow); + resumetext.setFillColor(sf::Color(229, 191, 9)); startmenutext.setFillColor(sf::Color::Black); quittext.setFillColor(sf::Color::Black); } else if( menu_index == 2) { resumetext.setFillColor(sf::Color::Black); - startmenutext.setFillColor(sf::Color::Yellow); + startmenutext.setFillColor(sf::Color(229, 191, 9)); quittext.setFillColor(sf::Color::Black); } else if( menu_index == 3) { resumetext.setFillColor(sf::Color::Black); startmenutext.setFillColor(sf::Color::Black); - quittext.setFillColor(sf::Color::Yellow); + quittext.setFillColor(sf::Color(229, 191, 9)); } // mouse placement - mouse_r.setPosition(((S_WIDTH / 2) + 60), ((S_HEIGHT / 2) - 45 + 50*(menu_index - 1))); - mouse_l.setPosition(((S_WIDTH / 2) - 58), ((S_HEIGHT / 2) + 2 + 50*(menu_index - 1))); + mouse_r.setPosition(((S_WIDTH / 2) + 60 - 7*(menu_index - 2)*(menu_index - 3) - 15*(menu_index - 1)*(menu_index - 2)), ((S_HEIGHT / 2) - 45 + 50*(menu_index - 1))); + mouse_l.setPosition(((S_WIDTH / 2) - 58 + 7*(menu_index - 2)*(menu_index - 3) + 15*(menu_index - 1)*(menu_index - 2)), ((S_HEIGHT / 2) - 45 + 50*(menu_index - 1))); } void Pause_menu::render(sf::RenderWindow& window) const diff --git a/src/Scoreboard_menu.cc b/src/Scoreboard_menu.cc index 82abec6..04f1e06 100644 --- a/src/Scoreboard_menu.cc +++ b/src/Scoreboard_menu.cc @@ -28,8 +28,7 @@ Scoreboard_menu::Scoreboard_menu() : texture{}, texture2{}, sprite{}, menu{false texture2.loadFromFile("assets/muspekare2.png"); mouse_l.setTexture(texture2); - mouse_l.setScale(0.1, 0.1); - mouse_l.setRotation(180); + mouse_l.setScale(-0.1, 0.1); sf::FloatRect gbm {mouse_l.getGlobalBounds()}; mouse_r.setTexture(texture2); @@ -45,24 +44,27 @@ Scoreboard_menu::Scoreboard_menu() : texture{}, texture2{}, sprite{}, menu{false scoreboardtext = sf::Text{ "Scoreboard:", font, 39 }; sf::FloatRect gbs {scoreboardtext.getGlobalBounds()}; scoreboardtext.setOrigin(gbs.width / 2, gbs.height / 2); - scoreboardtext.setPosition (S_WIDTH / 2 - 15, ((S_HEIGHT / 2) - 120)); + scoreboardtext.setPosition (S_WIDTH / 2 - 15, ((S_HEIGHT / 2) - 100)); scoreboardtext.setFillColor(sf::Color(153, 0, 0)); - // ----------------------------------------------------------------------- - // First place text + // Scorelist + // ----------------------------------------------------------------------- std::ifstream highscore_file_r{"assets/highscore.csv"}; - std::string csv_content {}; - for (std::string one_line; std::getline(highscore_file_r, one_line); csv_content += one_line + "p \n"); + std::string csv_content{}; + int index{0}; + for (std::string one_line; std::getline(highscore_file_r, one_line); csv_content += std::to_string(index) + ". " + one_line + "p \n") + { + ++index; + } firstplacetext = sf::Text{ csv_content , font, 18 }; sf::FloatRect gbfp {firstplacetext.getGlobalBounds()}; firstplacetext.setOrigin(gbfp.width / 2, gbfp.height / 2); - firstplacetext.setPosition (S_WIDTH / 2 - 15, ((S_HEIGHT / 2) - 30)); + firstplacetext.setPosition (S_WIDTH / 2 - 15, S_HEIGHT / 2); firstplacetext.setFillColor(sf::Color(153, 0, 0)); - // ----------------------------------------------------------------------- // Start menu text @@ -99,8 +101,8 @@ void Scoreboard_menu::update(Context& context) } // mouse placement - mouse_r.setPosition(((S_WIDTH / 2) + 45), ((S_HEIGHT / 2) + 65 + 50*(menu_index - 1))); - mouse_l.setPosition(((S_WIDTH / 2) - 73), ((S_HEIGHT / 2) + 112 + 50*(menu_index - 1))); + mouse_r.setPosition(((S_WIDTH / 2) + 45 - 30*(menu_index - 1)), ((S_HEIGHT / 2) + 65 + 50*(menu_index - 1))); + mouse_l.setPosition(((S_WIDTH / 2) - 73 + 30*(menu_index - 1)), ((S_HEIGHT / 2) + 65 + 50*(menu_index - 1))); } diff --git a/src/Start_menu.cc b/src/Start_menu.cc index bad9f3f..3b29b65 100644 --- a/src/Start_menu.cc +++ b/src/Start_menu.cc @@ -25,8 +25,7 @@ Start_menu::Start_menu() : texture{}, texture2{}, sprite{}, mouse_l{}, mouse_r{ texture2.loadFromFile("assets/muspekareGul.png"); mouse_l.setTexture(texture2); - mouse_l.setScale(0.1, 0.1); - mouse_l.setRotation(180); + mouse_l.setScale(-0.1, 0.1); sf::FloatRect gbm {mouse_l.getGlobalBounds()}; mouse_r.setTexture(texture2); @@ -73,26 +72,26 @@ void Start_menu::update(Context& context) // changes color on text depending on selection if( menu_index == 1) { - starttext.setFillColor(sf::Color::Yellow); + starttext.setFillColor(sf::Color(229, 191, 9)); scoreboardtext.setFillColor(sf::Color::Black); quittext.setFillColor(sf::Color::Black); } else if( menu_index == 2) { starttext.setFillColor(sf::Color::Black); - scoreboardtext.setFillColor(sf::Color::Yellow); + scoreboardtext.setFillColor(sf::Color(229, 191, 9)); quittext.setFillColor(sf::Color::Black); } else if( menu_index == 3) { starttext.setFillColor(sf::Color::Black); scoreboardtext.setFillColor(sf::Color::Black); - quittext.setFillColor(sf::Color::Yellow); + quittext.setFillColor(sf::Color(229, 191, 9)); } // mouse placement - mouse_r.setPosition(((S_WIDTH / 2) + 60), ((S_HEIGHT / 2) - 115 + 50*(menu_index - 1))); - mouse_l.setPosition(((S_WIDTH / 2) - 58), ((S_HEIGHT / 2) - 68 + 50*(menu_index - 1))); + mouse_r.setPosition(((S_WIDTH / 2) + 60 - 17*(menu_index - 1)*(menu_index - 2)), ((S_HEIGHT / 2) - 117 + 50*(menu_index - 1))); + mouse_l.setPosition(((S_WIDTH / 2) - 58 + 17*(menu_index - 1)*(menu_index - 2)), ((S_HEIGHT / 2) - 117 + 50*(menu_index - 1))); } diff --git a/src/States.h b/src/States.h index 4776ae5..2cb0b45 100644 --- a/src/States.h +++ b/src/States.h @@ -166,6 +166,7 @@ private: sf::String playerInput; sf::Text playerText; sf::Text linetext; + sf::Text funfacttext; sf::Text entertext; sf::Text pointstext; sf::Text savetext;