worked om backspace, mgameover menu - Alma, Malin
authormalak585 <malak585@su02-106.ad.liu.se>
Fri, 1 Dec 2023 14:04:05 +0000 (15:04 +0100)
committermalak585 <malak585@su02-106.ad.liu.se>
Fri, 1 Dec 2023 14:04:05 +0000 (15:04 +0100)
assets/data.json
assets/highscore.csv
src/Menus.cc

index 05c496547c14ca17ae1971221966c052870124e2..679dcef111cdacac471076e5e25b424cbfb3293e 100644 (file)
@@ -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
index ff371ab2612ff6daf9e6d64c5e08723f8acd9a00..6bb3686664493b73fa8555175f567918d066af9e 100644 (file)
@@ -2,4 +2,4 @@ gorilla, 5
 Lukas, 5
 gorilla, 4
 gorilla, 3
-gorilla, 2
+, 3
index 3dca3d65bcf0fe090e27c6d031d9ac8902922a77..46a03afcef691b6d4d3a11f278d8e09896b53c7b 100644 (file)
@@ -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);
+        }
+
     }