Esempio n. 1
0
// Objects using screen coordinates
void RenderScreenObjects()
{
	render.SetVerticesLocation( VERTICESLOCATION_SCREEN );

	/*render.m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
	render.m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	render.m_D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
	render.m_D3DDevice->SetTexture( 0, test_texture );*/

	/*render.SetDrawColor( 255, 255, 255 );
	render.SetTexture( "TestTexture" );
	render.DrawTexturedRect( 100, 100, 128, 128 );

	render.SetDrawColor( 255, 0, 0 );
	render.DrawRect( 200, 200, 50, 50 );*/

	/*render.SetDrawColor( 255, 255, 255 );
	render.SetTexture( "TestTexture2" );

	for ( int i = 0; i < 10; i++ )
	{
		for ( int j = 0; j < 10; j++ )
		{
			render.DrawTexturedRect( i*128, j*128, 128, 128 );
		}
	}*/

	RenderShip();
	RenderShipBullet();
	RenderInvaders();
	RenderScore();
	
	//RenderTitle();
	//RenderGrid();
}
void Game::Loop() {    
    InputKey key = _input.ReadInput();
    switch (key) {
        case Quit:
            _playing = false;
            break;
        case Up:
            _userPaddle.Move(-1);
            break;
        case Down:
            _userPaddle.Move(1);
            break;
        default:
            break;
    }    
        
    //clear();
    RenderScore();
    _gameBall.Render();
    _userPaddle.Render();
    _cpuPaddle.Render();
    //refresh();
}
Esempio n. 3
0
// ----------------------------------------------------------------------------
//  Name: RenderGameScreen
//
//  Desc: 
// ----------------------------------------------------------------------------
HRESULT CGame::RenderGameScreen()
{
	FLOAT x, y;

	x = 0;
	y = 0;

	// See RenderBoard function below.
	RenderBoard();

	// Print the little help message at the bottom.
	// X, Y, color, text.
	m_pText->Print( 200, (m_dwWinHeight) - 50, 0xFF0000FF, "Press Esc to quit and go back to the main menu." );

	// Render the paddle and the ball.
	m_pPaddle->Render( m_pDevice );
	m_pBall->Render( m_pDevice );

	// Render the remaining bricks in the map.
	for( int i = 0; i < 100; i++ )
	{
		switch( m_tMap[i] )
		{
		case '0':
			// Do nothing. Brick got destroyed or wasn't there in the first place.
			break;

		case '1':
			// Red brick.
			// Just calculate the position of the brick, then render it.
			// TODO: refactor this so the calculation is only done once in one place.
			m_pRedBrick->SetPosition( (-0.9f + (0.19f * x)), (0.4 - (0.08 * y)) + 0.5f, 0.0f );
			m_pRedBrick->Render( m_pDevice );

			break;

		case '2':
			// Green brick.
			// TODO: refactor this so the calculation is only done once in one place.
			m_pGreenBrick->SetPosition( (-0.9f + (0.19f * x)), (0.4 - (0.08 * y)) + 0.5f, 0.0f );
			m_pGreenBrick->Render( m_pDevice );
			break;

		case '3':
			// Blue brick;
			// TODO: refactor this so the calculation is only done once in one place.
			m_pBlueBrick->SetPosition( (-0.9f + (0.19f * x)), (0.4 - (0.08 * y)) + 0.5f, 0.0f );
			m_pBlueBrick->Render( m_pDevice );

			break;
		}

		x++;

		if( x > 9 )
		{
			x = 0;
			y++;
		}
	}

	RenderScore();

	return D3D_OK;
}