Ejemplo n.º 1
0
void render()
{    
	// Clears the buffer with this colour attribute
	clearBuffer(0x00);

	// Set up sample colours, and output shadings
	COORD c;

	// displays the framerate
	std::ostringstream ss;
	ss << std::fixed << std::setprecision(3);
	ss << 1.0 / deltaTime << "fps";
	c.X = ConsoleSize.X-9;
	c.Y = 0;
	writeToBuffer(c, ss.str());

	// displays the elapsed time
	ss.str("");
	ss << elapsedTime << "secs";
	c.X = 0;
	c.Y = 0;
	writeToBuffer(c, ss.str(), 0x59);

	if ( menu == 1 ) 
	{
		rendMainMenu();
	} 

	else if ( option == 1 ) 
	{ 
		rendOptions(); 
	}
	else if ( game == 1 )
	{
	c.X = 40;
	c.Y = 15;
	writeToBuffer(c, "In game state");
	flushBufferToConsole();
	}

	else if ( Ship ==  1 )
	{
		rendChoose();
	}
	flushBufferToConsole();
}
Ejemplo n.º 2
0
void render()
{    
    // Clears the buffer with this colour attribute
    clearBuffer(0x00);

    // Set up sample colours, and output shadings
    const WORD colors[] =   {
	                        0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,
	                        0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6
	                        };
	
    COORD c;

    // displays the framerate
    std::ostringstream ss;
    ss << std::fixed << std::setprecision(3);
    ss << 1.0 / deltaTime << "fps";
    c.X = ConsoleSize.X-9;
    c.Y = 0;
    writeToBuffer(c, ss.str());

    // displays the elapsed time
    ss.str("");
    ss << elapsedTime << "secs";
    c.X = 0;
	c.Y = ConsoleSize.Y - 1;
    writeToBuffer(c, ss.str(), 0x59);

	if (!levelStart)
		levelStart = initLevel();

	renderShip();
	moveBullets();
	checkBulletCollision(enemyArr, levelInfo.number);
	renderBullets();
	if (!spawnBufferCount && enemiesSpawned < levelInfo.number)
	{
		if (spawnEnemy(enemyArr, levelInfo.number))
		{
			spawnBufferCount += levelInfo.spawnBuffer;
			enemiesSpawned++;
		}
	}
	else if (spawnBufferCount) spawnBufferCount--;
	moveEnemy(enemyArr, levelInfo.number);
	checkBulletCollision(enemyArr, levelInfo.number);
	checkEnemyCollision(enemyArr, levelInfo.number);
	renderEnemy(enemyArr, levelInfo.number);
	if (levelInfo.bullets)
	{
		if (spawnEnemyBullet(enemyArr))
		{
				spawnBufferCount += bulletInfo.spawnBuffer;
		}
		moveEnemy(enemyBulletArr, bulletInfo.number);
		checkEnemyCollision(enemyBulletArr, bulletInfo.number);
		renderEnemy(enemyBulletArr, bulletInfo.number);
	}
	
	// Writes the buffer to the console, hence you will see what you have written
    flushBufferToConsole();

	if (enemiesSpawned == levelInfo.number) 
	{
		if (checkClear(enemyArr, levelInfo.number)) 
		{
			levelStart = false;
			enemiesSpawned = 0;
			spawnBufferCount = 0;
			delete[] enemyArr;
			delete[] enemyBulletArr;
			levelInfo.level = levelInfo.nextLevel;
		}
	}
}