File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed
Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ struct Button {
5151};
5252int main ()// przetwarza sterowanie u¿ytkownika, renderuje okno, tworzy obiekt gry
5353{
54+
5455 bool isEnd=true ;
5556 while (isEnd) {
5657 Terrarium::mapType selectedMapType = Terrarium::mapType::pusta;
Original file line number Diff line number Diff line change @@ -250,6 +250,15 @@ void Terrarium::restartGame()
250250 setUpTiles ();
251251}
252252
253+ void Terrarium::zapiszWynikDoPliku (std::string nazwaPliku)
254+ {
255+ std::ofstream plik (nazwaPliku, std::ios::app);
256+ if (!plik.is_open ())
257+ return ;
258+ plik << " Wynik: " <<snakeLenght<<std::endl;
259+ plik.close ();
260+ }
261+
253262void Terrarium::updateGameState (sf::RenderWindow *window, sf::Clock *gameClock, sf::Clock * fruitClock)
254263{
255264 for (int i = 0 ; i < rozmiarPlanszy; i++) {
@@ -366,6 +375,6 @@ void Terrarium::endGame(){
366375 scoreText.setString (" Koniec gry!\n Twoj wynik to " + std::to_string (snakeLenght));
367376 scoreText.setOrigin (sf::Vector2f (scoreText.getGlobalBounds ().width / 2 , scoreText.getGlobalBounds ().height / 2 ));
368377 scoreText.setPosition (sf::Vector2f (rozmiarPlanszy * 50 / 2 , rozmiarPlanszy * 50 / 2 ));
369-
378+ zapiszWynikDoPliku ( " wyniki.txt " );
370379
371380}
Original file line number Diff line number Diff line change 11#include " pole.h"
22#include < vector>
3+ #include < fstream>
34#ifndef TERRARIUM_H
45#define TERRARIUM_H
56class Terrarium
@@ -36,6 +37,7 @@ class Terrarium
3637
3738
3839 void endGame ();
40+ void zapiszWynikDoPliku (std::string nazwaPliku);
3941 void restartGame ();
4042};
4143#endif
Original file line number Diff line number Diff line change 1+ Wynik: 9
You can’t perform that action at this time.
0 commit comments