First of all let me tell you, I've studied C and C++, but my knowledge of OOP is very limited. I basically want that as soon as I create an object to class output, my whole array outpt be initialized to blank spaces (char no. 32). MAXROWS and MAXCOLS are defined as const int, currently 25 and 80 but I may change them.
class output{
private:
int score;
char outpt[MAXROWS][MAXCOLS];
void rand_platform()
{
int platform_start = rand() % (MAXCOLS-20);
int platform_length = rand() % 10 + 10;
for (int i=0; i<platform_length; i++) {
outpt[MAXROWS-1][platform_start+i]=219;
}
}
void bring_screen_down()
{ //this part brings whole screen 1 row up
score++;
for (int i=1;i<MAXROWS;i++) {
for (int j=0;j<MAXCOLS;j++) {
outpt[i-1][j] = outpt[i][j];
}
}
for (int j=0;j<MAXCOLS;j++) {
outpt[MAXROWS-1][j] = 0;
}
if (!(score%10))
rand_platform();
}
public:
void print()
{
system("CLS");
for (int i=0; i<MAXCOLS/2-2;i++)
cout << ' ';
printf("%04d\n",score);
for (int i=0;i<MAXROWS;i++) {
for (int j=0;j<MAXCOLS;j++) {
cout << outpt[i][j];
}
cout << endl;
}
bring_screen_down();
Sleep(200); // alternately for(int i=0; i<3500000;i++);
}
void output()
{
score=0;
fill_n(outpt, num_space_req, ' ');
}
};