From: malak585 Date: Fri, 1 Dec 2023 14:04:05 +0000 (+0100) Subject: worked om backspace, mgameover menu - Alma, Malin X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=ccbbc207c29a90d7fa2e680e580a95bd344305b3;p=TDDC76_proj.git worked om backspace, mgameover menu - Alma, Malin --- diff --git a/assets/data.json b/assets/data.json index 05c4965..679dcef 100644 --- a/assets/data.json +++ b/assets/data.json @@ -29,7 +29,7 @@ "game_constants": { "bottles_per_second" : 2, - "game_time" : 20, + "game_time" : 2, "yf_per_second": 0.125, "bikes_per_second": 0.17, "scoreboard" : 5 diff --git a/assets/highscore.csv b/assets/highscore.csv index ff371ab..6bb3686 100644 --- a/assets/highscore.csv +++ b/assets/highscore.csv @@ -2,4 +2,4 @@ gorilla, 5 Lukas, 5 gorilla, 4 gorilla, 3 -gorilla, 2 +, 3 diff --git a/src/Menus.cc b/src/Menus.cc index 3dca3d6..46a03af 100644 --- a/src/Menus.cc +++ b/src/Menus.cc @@ -696,8 +696,29 @@ void GameOver_menu::handle_input(sf::Event& event) // enter name if (event.type == sf::Event::TextEntered) { - playerInput += event.text.unicode; - playerText.setString(playerInput); + // delete last charakter with backspace + if (sf::Keyboard::isKeyPressed( sf::Keyboard::Backspace )) + { + if(!playerInput.isEmpty()) + { + std::cout << "yey" << std::endl; + playerInput.erase(playerInput.getSize() - 1, 1); + } + + else + { + return; + } + + } + + + else + { + playerInput += event.text.unicode; + playerText.setString(playerInput); + } + }