This is a function from a class that I believe to be the cause of the problem:
void Game::processGameScreen()
{
cout << "\nGAME PROCESS STARTED";
tetriminoInPlay = new Tetrimino;
tetriminoOnDeck = new Tetrimino;
int count = 0;
while (window.isOpen() && gameWell.topReached() == false)
{
//check for events and create tetrimino pointers
sf::Event event;
while (window.pollEvent(event)) {
//check for arrow key presses
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up)
{
tetriminoInPlay->rotateRight();
if (gameWell.tetriminoFit(*tetriminoInPlay) == false)
tetriminoInPlay->rotateLeft();
}
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left)
{
tetriminoInPlay->moveLeft();
if (gameWell.tetriminoFit(*tetriminoInPlay) == false)
tetriminoInPlay->moveRight();
}
else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right)
{
tetriminoInPlay->moveRight();
if (gameWell.tetriminoFit(*tetriminoInPlay) == false)
tetriminoInPlay->moveLeft();
}
else if (event.type == sf::Event::Closed)
window.close();
//counter to move pieces down
cout << "\n" << count;
if (count % 15 == 0 ) {
cout << "\nMOVING DOWN";
tetriminoInPlay->moveDown();
//check if it fits
if (gameWell.tetriminoFit(*tetriminoInPlay) == false) {
tetriminoInPlay->moveUp();
gameWell.addTetriminoToWell(*tetriminoOnDeck);
delete tetriminoInPlay;
score = score + gameWell.clearFullRows(); //add combo scoring later
//check for game over
if (gameWell.topReached() == false) {
tetriminoInPlay = tetriminoOnDeck;
tetriminoInPlay->setLocation(0,4);
delete tetriminoOnDeck;
tetriminoOnDeck = new Tetrimino;
}
}
}
count++;
//clear window, draw well, tetro, window.display
window.clear(sf::Color::White);
//draw tetriminoOnDeck !!!Figure out where to draw this at some point!!!
//drawTetrimino(tetriminoOnDeck, LAYOUT_BOARD_TOP, LAYOUT_BOARD_LEFT, BLOCK_SIZE_PIXELS);
drawWell(gameWell, LAYOUT_BOARD_TOP, LAYOUT_BOARD_LEFT, BLOCK_SIZE_PIXELS);
drawTetrimino(tetriminoInPlay, LAYOUT_BOARD_TOP, LAYOUT_BOARD_LEFT, BLOCK_SIZE_PIXELS);
drawScore(score, 50, 50);
window.display();
}
}
}
I believe the issue is with pointers somewhere. I can't locate the exact problem or even under what circumstance the problem occurs, as it is seemingly inconsistent on when it happens.
This is also present in the error:
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
I'm using the SFML graphics library if that matters.