コード例 #1
0
void CSpaceInvadersAppView::ConstructL( const TRect& aRect,
                                        CSpaceInvadersAppUi* aAppUi,
                                        CShipEngine* aShip,
                                        THighscoreHolder* aHolder)
{
    // Create a window for this application view
    CreateWindowL();

    // Set the windows size
    SetRect( aRect );
    // Sets the extent of the screen so it draws on the places of status pane
    // and options pane
    SetExtentToWholeScreen();

    iShip               = aShip;
    iAppUi              = aAppUi;
    iTickCounter        = 0;
    iShotCounter        = 0;
    iMaxHorizontalMoves = Rect().Width() / (6 * ship_width) + 2;
    iHorizontalMoves    = 2;
    iHolder 		    = aHolder;

    // Creates the alien CShipEngine -objects and places them to start positions
    InitAliens();

    TInt error;
    TRAP(error, LoadBitmapsL());
    if ( error )
    {
        iAppUi->Exit();
    }

    // Activate the window, which makes it ready to be drawn
    ActivateL();
}
コード例 #2
0
void PlayerController::Initalise(SDL_Surface* marineSprite, SDL_Surface* alienSprite,
	SDL_Surface* markers, SDL_Surface* healthBar, Level *level)
{
	vector<int> spawnTiles;
	int spawnCounter = 0;
	int currTile = 0;
	int currUnit = 0;
	int lastUnit = 0;
	int spawnDone = 0;

	if(mPlayAsMarines)
	{
		InitMarines(marineSprite, markers, healthBar);
	}
	else
	{
		InitAliens(alienSprite, markers, healthBar);
	}

	//Spawns all the units on the correct tiles (must have less tiles then the amount of units
	for(unsigned int t = 0; t < level->GetFloorTileAmount(); t++)
	{
		if(level->GetFloorTile(t)->GetTileType() == 8)
		{
			spawnCounter += 1;
			spawnTiles.push_back(t);
		}
	}

	spawnDone = spawnCounter;

	while(spawnDone > 0)
	{
		for(currUnit = lastUnit; currUnit < mPlayerUnits.size() / spawnCounter + lastUnit; currUnit++)
		{
			mPlayerUnits[currUnit]->SetPosX(level->GetFloorTile(spawnTiles[currTile])->GetPosX() + rand() % 32);
			mPlayerUnits[currUnit]->SetPosY(level->GetFloorTile(spawnTiles[currTile])->GetPosY() + rand() % 32);
		}
		if(currTile > spawnTiles.size())
		{
			currTile = 0;
		}
		else
		{
			currTile += 1;
		}

		lastUnit = currUnit;
		spawnDone -= 1;
	}
}
コード例 #3
0
void CSpaceInvadersAppView::GameOver()
{
    StopTimer();
    InitAliens();
    iAppUi->ChangeView(iAppUi->HighscoreView());
}