From eba50833d377eb16e83fb7d9b2ff0e608ae0c164 Mon Sep 17 00:00:00 2001 From: lukel495 Date: Thu, 30 Nov 2023 15:17:18 +0100 Subject: [PATCH] =?utf8?q?Namn=20l=C3=A4ggs=20nu=20in=20i=20csv=20filen=20?= =?utf8?q?fr=C3=A5n=20gameover:=20Lukas,=20Alma,=20Malin?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- assets/data.json | 2 +- assets/highscore.csv | 2 +- src/Menus.cc | 6 +++--- src/States.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/data.json b/assets/data.json index 679dcef..05c4965 100644 --- a/assets/data.json +++ b/assets/data.json @@ -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 diff --git a/assets/highscore.csv b/assets/highscore.csv index 2d4adab..ff371ab 100644 --- a/assets/highscore.csv +++ b/assets/highscore.csv @@ -1,5 +1,5 @@ gorilla, 5 +Lukas, 5 gorilla, 4 gorilla, 3 gorilla, 2 -gorilla, 1 diff --git a/src/Menus.cc b/src/Menus.cc index 8e76914..3dca3d6 100644 --- a/src/Menus.cc +++ b/src/Menus.cc @@ -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 lines_read; diff --git a/src/States.h b/src/States.h index 0811992..4776ae5 100644 --- a/src/States.h +++ b/src/States.h @@ -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; -- 2.30.2