I had the piece falling down the bucket correctly and then I implemented the following classes in order to stop the piece and there is a problem with my logic that I am not seeing. Any guidance would be appreciated. Thx
int main() // main function
{
srand (time(0));
initializeBucket(); // creates bucket
char answer; // declares answer
cout << "Would you like to play tetris (y/n)?" << endl; // asks user to play
cin >> answer; // input user response
while (answer == 'y') // if-then loop to determine gameplay depending on user response
{
int shapeType = rand() % 7 + 1; // declare and assign random integer to represent tetris shapes
TetrisShape currentShape(shapeType);
TetrisShape nextShape(shapeType);
updateBucket(currentShape); // calls display shape function
displayBucket(); // displays bucket
for (int x = 0; x < SHAPE; x++)
{
for (int y = 0; y < SHAPE; y++)
{
if (currentShape.shapeArray[x][y] != ' ')
{
if (x < 25 && y < 12)
{
if (bucket[x][y] != ' ')
{
// check for line
currentShape.setShape(nextShape);
int a = rand() % 7 + 1;
nextShape.setShape(a);
}
}
elseif (x = 25)
{
// check for line
currentShape.setShape(nextShape);
int a = rand() % 7 + 1;
nextShape.setShape(a);
}
else
{
int newshapeTopLefty = currentShape.shapeTopLefty;
int newshapeTopLeftx = currentShape.shapeTopLeftx + 1;
for (int x = currentShape.shapeTopLeftx; x < currentShape.shapeTopLeftx + 4; x++)
{
for (int y = currentShape.shapeTopLefty; y < currentShape.shapeTopLefty + 4; y++)
{
bucket[x][y] = ' ';
}
}
currentShape.setshapeTopLefty(newshapeTopLefty);
currentShape.setshapeTopLeftx(newshapeTopLeftx);
updateBucket(currentShape);
displayBucket();
if (false == processDownArrow(currentShape))
{
// check for line
currentShape.setShape(nextShape);
int a = rand() % 7 + 1;
nextShape.setShape(a);
}
else
{
int newshapeTopLefty = currentShape.shapeTopLefty;
int newshapeTopLeftx = currentShape.shapeTopLeftx + 1;
for (int x = currentShape.shapeTopLeftx; x < currentShape.shapeTopLeftx + 4; x++)
{
for (int y = currentShape.shapeTopLefty; y < currentShape.shapeTopLefty + 4; y++)
{
bucket[x][y] = ' ';
}
}
currentShape.setshapeTopLefty(newshapeTopLefty);
currentShape.setshapeTopLeftx(newshapeTopLeftx);
updateBucket(currentShape);
displayBucket();
}
}
}
}
}
Sleep(3000);
}
cout << "Goodbye!" << endl;
system("pause"); // pauses application before end
return 0; // end main function
}