Namn läggs nu in i csv filen från gameover: Lukas, Alma, Malin
authorlukel495 <lukel495@tlvm-4-1-1.ad.liu.se>
Thu, 30 Nov 2023 14:17:18 +0000 (15:17 +0100)
committerlukel495 <lukel495@tlvm-4-1-1.ad.liu.se>
Thu, 30 Nov 2023 14:17:18 +0000 (15:17 +0100)
assets/data.json
assets/highscore.csv
src/Menus.cc
src/States.h

index 679dcef111cdacac471076e5e25b424cbfb3293e..05c496547c14ca17ae1971221966c052870124e2 100644 (file)
@@ -29,7 +29,7 @@
     "game_constants":
     {
         "bottles_per_second" : 2,
-        "game_time" : 2,
+        "game_time" : 20,
         "yf_per_second": 0.125,
         "bikes_per_second": 0.17,
         "scoreboard" : 5
index 2d4adabdf9a30c852dfa39bfd4ac6bf685ec695e..ff371ab2612ff6daf9e6d64c5e08723f8acd9a00 100644 (file)
@@ -1,5 +1,5 @@
 gorilla, 5
+Lukas, 5
 gorilla, 4
 gorilla, 3
 gorilla, 2
-gorilla, 1
index 8e76914e8da5e2b0c42406a9f83ee24b86c31532..3dca3d65bcf0fe090e27c6d031d9ac8902922a77 100644 (file)
@@ -647,7 +647,7 @@ void GameOver_menu::handle_input(sf::Event& event)
 
             if(menu_index == 1)
             {
-                load_to_csv();
+                load_to_csv(playerText);
                 menu = true;
                 menu_index = 1;
             }
@@ -704,9 +704,9 @@ void GameOver_menu::handle_input(sf::Event& event)
 }
 
 //spara namn till fil
-void GameOver_menu::load_to_csv()
+void GameOver_menu::load_to_csv(sf::Text playertext)
 {
-    std::string current_line{"Gorilla, " + std::to_string(points)};
+    std::string current_line{playerText.getString() + ", " + std::to_string(points)};
 
     std::ifstream highscore_file_r{"assets/highscore.csv"};
     std::vector<std::string> lines_read;
index 0811992f1786c9bd7dd4090929d004b001b9e225..4776ae5bebecdc6c6e8aa74b7204c0817ab484f9 100644 (file)
@@ -154,7 +154,7 @@ public:
     void update(Context& context) override;
     void render(sf::RenderWindow& window) const override;
     void handle_input(sf::Event& event) override;
-    void load_to_csv();
+    void load_to_csv(sf::Text playerText);
 
 private:
     sf::Texture texture;