From: lukel495 Date: Thu, 30 Nov 2023 14:17:18 +0000 (+0100) Subject: Namn läggs nu in i csv filen från gameover: Lukas, Alma, Malin X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=eba50833d377eb16e83fb7d9b2ff0e608ae0c164;p=TDDC76_proj.git Namn läggs nu in i csv filen från gameover: Lukas, Alma, Malin --- 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;