Well, I'm still working on my console game, but its save funcion is messed up. It should write the visible map to a file, but when it writes it, it doesnt write it like what the map looks like.
Only problem is that there are two squares that always come up at the very start of the writing... I cant figure out why?
Anyone?
Code:
void Save() {
COORD Pos;
HANDLE hOt = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD reader;
char buffer[2027];
char DELO[1];
int x_pos, y_pos;
SHORT bc;
ofstream file_out(MAINPATHNAME);
if(!file_out) {
clrscr();
cout << "Unable to open file!";
}
for(y_pos=0; y_pos <= 24; y_pos++)
for(x_pos=0; x_pos <= 80; x_pos++){
bc++;
Pos.X = x_pos;
Pos.Y = y_pos;
ReadConsoleOutputCharacter(hOt, &DELO[0], 1, Pos, &reader);
if(x_pos == 80) {
buffer[bc] = 'W';
} else
buffer[bc] = DELO[0];
}
for(bc=0; bc < 2027; bc++) {
if(buffer[bc] == 'W')
file_out << endl;
else
file_out << buffer[bc];
}
file_out.close();
clrscr();
exit(0);
}