I'm tackling this Tetris tutorial and so far understanding it piece by piece, but I have arrived at a point that has stumped me. This is the tutorial in question:
My question regards a small issue of scope and functions. This is the Pieces class with the function in question, in a header file:
#ifndef _PIECES_
#define _PIECES_
class Pieces
{
public:
int GetBlockType (int pPiece, int pRotation, int pX, int pY);
int GetXInitialPosition (int pPiece, int pRotation);
int GetYInitialPosition (int pPiece, int pRotation);
};
#endif // _PIECES_
Now here is the function GetBlockType() in a .cpp file.
int Pieces::GetBlockType (int pPiece, int pRotation, int pX, int pY)
{
return mPieces [pPiece][pRotation][pX][pY];
}
The compiler tells me that mPieces
is an undeclared identifier. There is a variable called mPieces
, but I have declared it in main.cpp.
Is the problem an issue of scope? Have I declared mPieces
in the wrong place? I've tried my hand at it and give up, so maybe someone here can help.