Witam,
Jak mógłbym zrobić save do tego kodu:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
int liczba, strzal, ile_prob=0, wybor, wybor2, monety=0, exp=0, poziom=1;
int main()
{
//kolory :P
HANDLE hOut;
hOut = GetStdHandle( STD_OUTPUT_HANDLE );
while(1)
{
SetConsoleTextAttribute( hOut, 0x0006 );
ile_prob=0;
cout<<""<<endl;
cout<<""<<endl;
cout<<"---Promocja Swiateczna Trwa!----"<<endl;
cout<<""<<endl;
cout<<""<<endl;
cout<<"-----MENU-----"<<endl;
cout<<"1.Graj"<<endl;
cout<<"2.Challanges"<<endl;
cout<<"3.Sklep(Dostepne tylko w swieta!)"<<endl;
cout<<"Twoje monety:"<<monety<<endl;
cout<<"Twoj exp:"<<exp<<endl;
cout<<"Twoj poziom:"<<poziom<<endl;
cin>>wybor;
//Funkcja poziomów
if(exp==100)
{
poziom = poziom + 1;
exp = 0;
}
if(wybor==1)
{
SetConsoleTextAttribute( hOut, 0x0003 );
cout<<"Witaj! Pomyslalem sobie liczbe 1..100"<<endl;
srand(time(NULL));
liczba = rand()%100+1;
while(strzal!=liczba)
{
ile_prob++;
SetConsoleTextAttribute( hOut, 0x0001 );
cout<<"Zgadnij jaka (to Twoja "<<ile_prob<<" proba): ";
cin>>strzal;
if(strzal==liczba)
{
SetConsoleTextAttribute( hOut, 0x00052 );
cout<<"Udalo sie! Wygrywasz w "<<ile_prob<<" probie"<<endl;
cout<<"Brawo zdobywasz 15 monet!"<<endl;
monety = monety + 15;
exp = exp + 50;
}
else if(strzal<liczba)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"To za malo"<<endl;
}
else if(strzal>liczba)
{
SetConsoleTextAttribute( hOut, 0x0002 );
cout<<"To za duzo"<<endl;
}
}
getchar();
getchar(); //dla pewnosci 2 razy
}
//CHALLANGES!
if(wybor==2)
{
cout<<"Lista challanegow: "<<endl;
cout<<"1.Wygraj w mniej niz 10 probach!"<<endl;
cout<<"2.Wygraj w mniej niz 5 probach!"<<endl;
cout<<"3.Poradzisz sobie z 500 liczbami?"<<endl;
cin>>wybor2;
if(wybor2==1)
{
//1 challange
SetConsoleTextAttribute( hOut, 0x0003 );
cout<<"Witaj! Pomyslalem sobie liczbe 1..100"<<endl;
srand(time(NULL));
liczba = rand()%100+1;
while(strzal!=liczba)
{
ile_prob++;
SetConsoleTextAttribute( hOut, 0x0001 );
cout<<"Zgadnij jaka (to Twoja "<<ile_prob<<" proba): ";
cin>>strzal;
if(ile_prob>10)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"Przegrales! :("<<endl;
exit(0);
}
if(strzal==liczba)
{
SetConsoleTextAttribute( hOut, 0x00052 );
cout<<"Udalo sie! Wygrywasz w "<<ile_prob<<" probie"<<endl;
cout<<"Brawo zdobywasz 20 monet!"<<endl;
monety = monety + 20;
exp = exp + 20;
ile_prob==0;
}
else if(strzal<liczba)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"To za malo"<<endl;
}
else if(strzal>liczba)
{
SetConsoleTextAttribute( hOut, 0x0002 );
cout<<"To za duzo"<<endl;
}
}
getchar();
getchar(); //dla pewnosci 2 razy
}
if(wybor2==2)
{
//1 challange
SetConsoleTextAttribute( hOut, 0x0003 );
cout<<"Witaj! Pomyslalem sobie liczbe 1..100"<<endl;
srand(time(NULL));
liczba = rand()%100+1;
while(strzal!=liczba)
{
ile_prob++;
SetConsoleTextAttribute( hOut, 0x0001 );
cout<<"Zgadnij jaka (to Twoja "<<ile_prob<<" proba): ";
cin>>strzal;
if(ile_prob>5)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"Przegrales! :("<<endl;
exit(0);
}
if(strzal==liczba)
{
SetConsoleTextAttribute( hOut, 0x00052 );
cout<<"Udalo sie! Wygrywasz w "<<ile_prob<<" probie"<<endl;
cout<<"Brawo zdobywasz 25 monet!"<<endl;
monety = monety + 25;
exp = exp + 25;
ile_prob==0;
}
else if(strzal<liczba)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"To za malo"<<endl;
}
else if(strzal>liczba)
{
SetConsoleTextAttribute( hOut, 0x0002 );
cout<<"To za duzo"<<endl;
}
}
getchar();
getchar(); //dla pewnosci 2 razy
}
if(wybor2==3)
{
//1 challange
SetConsoleTextAttribute( hOut, 0x0003 );
cout<<"Witaj! Pomyslalem sobie liczbe 1..500"<<endl;
srand(time(NULL));
liczba = rand()%500+1;
while(strzal!=liczba)
{
ile_prob++;
SetConsoleTextAttribute( hOut, 0x0001 );
cout<<"Zgadnij jaka (to Twoja "<<ile_prob<<" proba): ";
cin>>strzal;
if(strzal==liczba)
{
SetConsoleTextAttribute( hOut, 0x00052 );
cout<<"Udalo sie! Wygrywasz w "<<ile_prob<<" probie"<<endl;
cout<<"Brawo zdobywasz 30 monet!"<<endl;
monety = monety + 30;
exp = exp + 30;
ile_prob==0;
}
else if(strzal<liczba)
{
SetConsoleTextAttribute( hOut, 0x0004 );
cout<<"To za malo"<<endl;
}
else if(strzal>liczba)
{
SetConsoleTextAttribute( hOut, 0x0002 );
cout<<"To za duzo"<<endl;
}
}
getchar();
getchar(); //dla pewnosci 2 razy
}
}
if(wybor==3)
{
cout<<"1.Dodatkowe monety! +10 monet!"<<endl;
cout<<"2.Dodatkowy exp!"<<endl;
}
}
return 0;
}
Szukałem na googlach wszędzie i nic nie działa. Próbowałem wszystkiego i nic. Ale może wy pomożecie :). z góry dzięki za pomoc :-).
PS. Jakby ktoś pytał główkowałem nad tym i nie wiem jak zrobić ten save. Chodzi mi o zapis expa, monet, poziomu i ulepszeń kupionych w sklepie :)