Esempio n. 1
0
void Game::createBlock()
{
    switch (holdStatus){
        case PREPAREHOLD:
	    shape = BlockShape(*randomQueue->begin());
	    randomQueue->pop();
	    break;
	case HOLD:
	    if (holdEmpty){
		holdShape = shape;
		shape = BlockShape(*randomQueue->begin());
		randomQueue->pop();
		holdStatus = HOLDED;
		holdEmpty = false;
		show->holdShow(holdShape);
		ResourceData::sound->playChunk(Sound::TURN);
	    } else{
		std::swap(shape, holdShape);
		holdStatus = HOLDED;
		show->holdShow(holdShape);
		ResourceData::sound->playChunk(Sound::TURN);		
	    }
	    break;
	case HOLDED:
	    shape = BlockShape(*randomQueue->begin());
	    randomQueue->pop();	    
	    holdStatus = PREPAREHOLD;
	    break;
    }
    pos = blockStartPosArray[shape];
    direction = NORTH;
}
/*******************************************************************************
 *  select a random piece shape (BlocksShape Enum value 1-7), and sets it as the
 * current shape
 ******************************************************************************/
void BlocksPiece::setRandomShape()
{
    setShape(BlockShape(qrand() % 7 +1));
}