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");
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<float>(points)/static_cast<float>(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 };
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);
// 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)));
}
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);
}
// if not backspace, print letters
- else if(playerInput.getSize() < 30)
+ else if(playerInput.getSize() < 15)
{
playerInput += event.text.unicode;
}
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);
// 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
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);
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
}
// 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)));
}
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);
// 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)));
}
sf::String playerInput;
sf::Text playerText;
sf::Text linetext;
+ sf::Text funfacttext;
sf::Text entertext;
sf::Text pointstext;
sf::Text savetext;