Hello and thanks in advance. I need to create a Tetris project in C++, i have the boards and pieces classes but i want to do an initializer class, so what im doing is this
#include "Initializer.h"
void Initializer::drawBoard()
{
}
// --------------------------------- Public Part ----------------------- //
Initializer::Initializer(Board *bBoard, Pieces *pPieces)
{
}
void Initializer::drawScene()
{
bBoard->showBoard();
}
Here is the board class:
Board::Board(Pieces *mPieces)
{
for(int x = 0; x < 20; x++)
{
for(int y = 0; y < 10; y++)
{
mBoard[x][y] = 0;
}
}
}
void Board::showBoard()
{
for(int x = 0; x < 20; x++)
{
for(int y = 0; y < 10; y++)
{
if(mBoard[x][y] == 0)
{
cout << 0;
}
else
{
cout << "x";
}
}
cout << endl;
}
}
and the main function
#include "Pieces.h"
#include "Board.h"
#include "Initializer.h"
#include <iostream>
using namespace std;
int main(int numeroArgumentos, char *argumentos[])
{
srand (time(NULL));
int randomNumber = rand() % 6;
Pieces mPieces;
Board bBoard(&mPieces);
Initializer iIOS(&bBoard, &mPieces);
bBoard.showBoard();
iIOS.drawScene();
return 0;
}
the problem is, i get two different results when i execute the main function as you can see in the image (bBoard.showBoard is the left result, and the other one is the iIOS.drawScene())

What i have to do to get the correct board with the two functions?
Initializerconstructor doesn't do anything with its arguments.bBoardindrawScene.