Exemplo n.º 1
0
/*!
*/
void GridItem::checkLines(const QList<BallItem*> &balls)
{
    if (0 == balls.count())
        return;

    LinesTracker::set_of_positions_t *positions = new LinesTracker::set_of_positions_t;

    int n = balls.count();
    for (int i = 0; i < n; ++i) {
        LinesTracker::instance()->search(this, balls[i]);

        if (LinesTracker::instance()->horizontalLine().count() >= 5)
            insertIntoPositionSet(*positions, LinesTracker::instance()->horizontalLine());

        if (LinesTracker::instance()->verticalLine().count() >= 5)
            insertIntoPositionSet(*positions, LinesTracker::instance()->verticalLine());

        if (LinesTracker::instance()->diag1Line().count() >= 5)
            insertIntoPositionSet(*positions, LinesTracker::instance()->diag1Line());

        if (LinesTracker::instance()->diag2Line().count() >= 5)
            insertIntoPositionSet(*positions, LinesTracker::instance()->diag2Line());

        LinesTracker::instance()->clear();
    }

    if (positions->count()) {
        animateBalls(*positions);

        int score = removeLines(*positions);
        MainWidget::instance()->updateScore(score);
    }

    delete positions;
}
Exemplo n.º 2
0
/*******************************************************************************
 * Destructor.
 ******************************************************************************/
Bar::~Bar()
{
  hideInfo();

  removeLines();

  // Note that we need to check for dangling pointers before removing.
  if(scene() != NULL)
    scene()->removeItem(this);

  if(!network_.isNull())
    network_->removeBar(this);
}
Exemplo n.º 3
0
void Board::flashLines()
{
	m_flash_frame++;
	if (m_flash_frame < 6) {
		int amount = (m_flash_frame % 2) ? 7 : -7;

		for (int i = 0; i < 4; ++i) {
			int row = m_full_lines[i];
			if (row == -1) {
				break;
			}

			for (int col = 0; col < 10; ++col) {
				m_cells[col][row] += amount;
			}
		}

		update();
	} else {
		m_flash_timer->stop();
		m_flash_frame = -1;
		removeLines();
	}
}