コード例 #1
0
ファイル: interrupts.c プロジェクト: YazanHalawa/ECEn-427
void updateTankFlashing() {
	if (isTankHit() && TankFlashTime >= TANK_FLASH_TICKS && tankFlashNum != FLASH_TICKS){
		setExplosionFlag(1);
		tankFlashNum++;
		TankFlashTime = 0;
		TankFlashState = !TankFlashState;
		if (tankFlashNum <= 1)
			flashTank(TankFlashState, true);
		else
			flashTank(TankFlashState, false);
	}
	if (isTankHit() && tankFlashNum == FLASH_TICKS){
		tankFlashNum = 0;
		TankFlashState = true;
		flashTank(TankFlashState, false);
		setTankHit(false);
		setLives(getLives()-1);
		// Take out one of the lives
		int startRow = 5;
		int startCol = 490 + (getLives())*40;
		drawTank(true, startRow , startCol);
		// Check if game over
		if (getLives() == 0) {
			setEndOfGame(true);
		} else {
			setTankPositionGlobal(20); // Reset Tank
			drawTank(false, 0, 0);
		}
	}
	TankFlashTime++;
}
コード例 #2
0
void Escapist::findBorder(Field *mainField, Dot **myField, int line, int col)
{
	this->visit(myField);
	currentWave.push_back({ line, col });
	_metBorder = false;
	do
	{
		waves.push_back(currentWave);
		nextWave.clear();
		for (unsigned int i = 0; i < currentWave.size(); ++i)
		{
			if ((currentWave[i].line + 1) & 1)//odd row
			{
				findOddNeighbours(myField, currentWave[i].line, currentWave[i].col);
			}
			else//even row
			{
				findEvenNeighbours(myField, currentWave[i].line, currentWave[i].col);
			}
		}
		if (nextWave.size() == 0)
		{
			setEndOfGame(true);
			break;
		}
		currentWave = nextWave;
	} while (!_metBorder);
}
コード例 #3
0
Escapist::Escapist(Dot **myField)
{
	this->setColor(0.3, 0.3, 1.0);//blue
	this->getStartPos(myField);
	myField[_currPosX][_currPosY].setSolid(true);
	setEndOfGame(false);
}
コード例 #4
0
// Method for moving brick down,
// detects if new bricks should be spawned, also detects end of game
bool TetrisEngine:: moveDown()
{
    bool canContinue = true;

    for (int i= 0; i < BRICKCOUNT; i++)
    {
        // maximum allowed number for tile table is numRows * 10 - 1
        // if it exceeds brick should be stopped
        // or if its colliding with another brick
        if ((_curBrick->brickPosition[i] + _numCols > _numRows * 10 - 1)
                || (checkCollision(_curBrick->brickPosition[i] + _numCols)) )
        {
            canContinue = false;
            break;
        }
    }

    if (canContinue)
    {
        for (int i= 0; i < BRICKCOUNT; i++)
        {
            // going one row down by adding columns count
            _tiles[_curBrick->brickPosition[i]]->setUnactive();
            _curBrick->brickPosition[i] =
                    _curBrick->brickPosition[i] + _numCols;
        }

        // highlighting new tiles after changing all to avoid double highlight on one tile
        for (int i= 0; i < BRICKCOUNT; i++)
        {
            _tiles[_curBrick->brickPosition[i]]->setActive(resolveBrickColor(_curBrick->color));
        }
    }
    else
    {
        qDebug() << "Collision detected, end of life of brick";

        if (spawnBrick())
        {
            setEndOfGame(true);
        }
        // after spawnBrick, so old brick tiles will be unactive
        checkForLine();
    }

    return canContinue;
}
コード例 #5
0
ファイル: interrupts.c プロジェクト: YazanHalawa/ECEn-427
void checkGameOver() {
	if ((getAlienBlockPosition().y + ((getBottomRow()+1)*TOTAL_VERTICAL_DISTANCE_BETWEEN_ALIENS)) >= BUNKER_ROW_STOP) {
		setEndOfGame(true);
	}
}