-
problem
ok im making a very simple rpg and i need some help because it hasnt turned out the way i wanted it to. now to the details first off you need to have more than no brain to help me and know how to program in c++ (hopefully all of you have a brain) ok the problem is that when i start the prgram it ask for the name right but when it goes to display the map its just blank till yoiu hit a button 4 times then the map scrolls down the page rather fast and then goes blank again then yoiu need to press a button 4 times again if anyone coiuld help i thank yoiu in advanced
the code is attached
-
I downloaded your source and whoa!
Last of all, it wouldn't compile (missing this, missing that, undefined symbol, etc).
Second last of the rest you have multiple declarations of the same functions. Not that it really matters, but it kinds spoils the feeling... (?)
Then again, there's a function called `strcpy()' which is pretty handy when you need to set an array after wards. So, instead of
boards[9][9]='+';
boards[0][9]='+';
boards[9][0]='+';
boards[5][1]='=';
boards[5][2]='=';
do
strcpy(boards[0], "=++==++)
which will set the first row of `boards' (boards[0]) to =++==++.
Anyway, if can get a version of that file that compiles, feel free to repost.
-
compies fine with devC++ and visual C++
what compiler you useing?
-
bcc55. Anyway, split your source to multiple files to make it readable :-)
-
thanks for the knowledge on the strcpy function
-
ok i got another problem now im trying to save a file and read a file (not at the same time) but it keeps coming up with these errors
Code:
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(87) : error C2676: binary '>>' : 'class std::basic_ofstream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to
the predefined operator
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::al
locator<char> >' (or there is no acceptable conversion)
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
here is the code
Code:
void Save()
{
ofstream fout;
string szLine ="";
string szWord = "";
string Name = Name;
fout.open("Stats.dat");
fout << "Name: " <<Name <<endl;
fout << "Life: " <<Life <<endl;
fout << "Maxlife: " <<Maxlife <<endl;
fout << "Money: " <<Money <<endl;
fout << "Potions: " <<Potions <<endl;
fout << "Spells: " <<Spells <<endl;
fout << "Level: " <<Level <<endl;
fout << "NLevel: " <<NLevel <<endl;
fout << "EPoints: " <<EPoints <<endl;
fout << "EOld: " <<EOld <<endl;
fout << "EGained: " <<EGained <<endl;
fout << "Power: " <<Power <<endl;
fout << "PotionP: " <<PotionP <<endl;
fout << "MagicP: " <<MagicP <<endl;
fout.close();
}
void Open()
{
ifstream fin;
string szLine = "";
string szWord = "";
string szName = "";
fin.open("Stats.txt");
if(fin.fail())
{
cout << "ERROR: Could not find Stats.txt!\n";
return;
}
cout << endl;
while(fin >> szWord)
cout << szWord;
cout << endl;
fin.clear();
fin.seekg(NULL, ios::beg);
while(getline(fin, szLine))
cout << szLine << endl;
cout << endl;
fin.clear();
fin.seekg(NULL, ios::beg);
fin >> szWord >> Name;
fin >> szWord >> Life;
fin >> szWord >> Maxlife;
fin >> szWord >> Money;
fin >> szWord >> Potions;
fin >> szWord >> Spells;
fin >> szWord >> Level;
fin >> szWord >> NLevel
fin >> szWord >> EPoints;
fin >> szWord >> EOld;
fin >> szWord >> EGained;
fin >> szWord >> Power;
fin >> szWord >> PotionP;
fin >> szWord >> MagicP;
fin.close(); .
}
thanx if you can help