Ejemplo n.º 1
0
void QTetrixBoard::keyPressEvent( QKeyEvent *e )
{
    if ( noGame || isPaused || waitingAfterLine )
        return;
    switch( e->key() ) {
	case Key_Left :
	    moveLeft();
	    break;
	case Key_Right :
	    moveRight();
	    break;
	case Key_Down :
	    rotateRight();
	    break;
	case Key_Up :
	    rotateLeft();
	    break;
	case Key_Space :
	    dropDown();
	    break;
	case Key_D :
	    oneLineDown();
	    break;
        default:
	    return;
    }
    e->accept();
}
Ejemplo n.º 2
0
//! [13]
void TetrixBoard::keyPressEvent(QKeyEvent *event)
{
    if (!isStarted || isPaused || curPiece.shape() == NoShape) {
	QFrame::keyPressEvent(event);
        return;
    }
//! [13]

//! [14]
    switch (event->key()) {
    case Qt::Key_Left:
        tryMove(curPiece, curX - 1, curY);
	break;
    case Qt::Key_Right:
        tryMove(curPiece, curX + 1, curY);
	break;
    case Qt::Key_Down:
        tryMove(curPiece.rotatedRight(), curX, curY);
	break;
    case Qt::Key_Up:
        tryMove(curPiece.rotatedLeft(), curX, curY);
	break;
    case Qt::Key_Space:
	dropDown();
	break;
    case Qt::Key_D:
	oneLineDown();
	break;
    default:
	QFrame::keyPressEvent(event);
    }
//! [14]
}
Ejemplo n.º 3
0
void QTetrixBoard::timeout()
{
    if ( waitingAfterLine ) {
	timer->stop();
	waitingAfterLine = FALSE;
	newPiece();
	timer->start( timeoutTime );
    } else {
        oneLineDown();
    }
}
Ejemplo n.º 4
0
//! [15]
void TetrixBoard::timerEvent(QTimerEvent *event)
{
    if (event->timerId() == timer.timerId()) {
        if (isWaitingAfterLine) {
	    isWaitingAfterLine = false;
	    newPiece();
	    timer.start(timeoutTime(), this);
        } else {
            oneLineDown();
        }
    } else {
        QFrame::timerEvent(event);
//! [15] //! [16]
    }
//! [16] //! [17]
}
Ejemplo n.º 5
0
void ComplexTetris::timeoutElapsed(){
    if(hasStarted() && !isPaused() && !isGameOver()){
        oneLineDown();
    }
}
Ejemplo n.º 6
0
void ComplexTetris::moveDown(){
    oneLineDown();
}