@@ -9,6 +9,8 @@ Terrarium::Terrarium(mapType rodzajMapy) {
99 scoreText.setFont (arial);
1010 scoreText.setPosition (sf::Vector2f (rozmiarPlanszy*50 - 40 , 0 ));
1111 scoreText.setFillColor (sf::Color (0 , 0 , 0 , 255 ));
12+ scoreText.setOutlineColor (sf::Color (255 , 255 , 255 , 255 ));
13+ scoreText.setOutlineThickness (3 );
1214 prepareTextures ();
1315 setUpTiles ();
1416
@@ -138,26 +140,14 @@ void Terrarium::updateGameState(sf::RenderWindow *window, sf::Clock *gameClock,
138140 }
139141 if (!isEnd) {
140142 if (gameClock->getElapsedTime () >= sf::milliseconds (150 )) {
143+ scoreText.setString (std::to_string (snakeLenght));
141144 move ();
142145 gameClock->restart ();
143- scoreText.setString (std::to_string (snakeLenght));
144146 }
145- }
146- else {
147- std::cout << " Koniec gry!" << std::endl;
148- std::cout << " Twoj wynik to " << snakeLenght << std::endl;
149- scoreText.setString (" Koniec gry!\n Twoj wynik to " + std::to_string (snakeLenght));
150- scoreText.setOrigin (sf::Vector2f (scoreText.getGlobalBounds ().width / 2 , scoreText.getGlobalBounds ().height / 2 ));
151- scoreText.setPosition (sf::Vector2f (rozmiarPlanszy*50 / 2 , rozmiarPlanszy*50 / 2 ));
152-
153- window->draw (scoreText);
154- window->display ();
155- window->close ();
156- }
157-
158- if (fruitClock->getElapsedTime () >= sf::seconds (3 )) {
159- generateFruit ();
160- fruitClock->restart ();
147+ if (fruitClock->getElapsedTime () >= sf::seconds (3 )) {
148+ generateFruit ();
149+ fruitClock->restart ();
150+ }
161151 }
162152
163153 window->draw (scoreText);
@@ -237,6 +227,12 @@ void Terrarium::move() {
237227 plansza[headPos.x ][headPos.y ]->setSprite (&headTexture);
238228}
239229void Terrarium::endGame (){
240- // plansza.clear();
241230 isEnd = true ;
231+ std::cout << " Koniec gry!" << std::endl;
232+ std::cout << " Twoj wynik to " << snakeLenght << std::endl;
233+ scoreText.setString (" Koniec gry!\n Twoj wynik to " + std::to_string (snakeLenght));
234+ scoreText.setOrigin (sf::Vector2f (scoreText.getGlobalBounds ().width / 2 , scoreText.getGlobalBounds ().height / 2 ));
235+ scoreText.setPosition (sf::Vector2f (rozmiarPlanszy * 50 / 2 , rozmiarPlanszy * 50 / 2 ));
236+
237+
242238}
0 commit comments