From 0b419978387da7a81c82b5162cb820092fd529a2 Mon Sep 17 00:00:00 2001 From: Rommmmaha Date: Fri, 7 Jun 2024 12:43:40 +0300 Subject: [PATCH] . --- client/game.cpp | 17 ++++++++++++----- client/main.cpp | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/game.cpp b/client/game.cpp index a010f38..1927bdb 100644 --- a/client/game.cpp +++ b/client/game.cpp @@ -4,13 +4,8 @@ game::game() { srand(unsigned int(time(NULL))); - - fps = 10; - scale = 20; - debug = false; running = true; needInitialization = true; - number_of_enemies = 2; map = nullptr; tmp_map = nullptr; @@ -45,6 +40,14 @@ void game::clear() void game::init() { + + if (firstStart) + { + fps = 10; + scale = 20; + debug = false; + number_of_enemies = 2; + } // Preparing clear(); needInitialization = false; @@ -154,6 +157,7 @@ void game::update() } break; case sf::Keyboard::R: + firstStart = true; needInitialization = true; return; case sf::Keyboard::D: @@ -219,6 +223,7 @@ void game::update() // Check if player is on path if (map[pos2index(player.x, player.y, map_size.x)] == 2) { + damaged.play(); needInitialization = true; return; } @@ -349,6 +354,8 @@ void game::update() void game::draw() { + if (!running) + return; // - Render Start // Background diff --git a/client/main.cpp b/client/main.cpp index 43db77e..251120a 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -9,6 +9,7 @@ int main() _game.update(); _game.draw(); } + _game.clear(); return 0; } int WinMain()