コード例 #1
0
//RenderGame(TetrisGame* game) - depending on the game state, render the game 
void RenderGame(TetrisGame* game)
{
	if(game->state != TITLE_SCREEN)
	{
		//we are in main game mode, or a version of it - render from back to front
		RenderBackground(game);

		RenderBoard(game);

		//if the block is falling render it 
		if(game->state == BLOCK_FALLING)
		{
			RenderBlock(game,game->currentBlockPos[0] * BLOCK_SIZE + GAME_BOARD_TOP_LEFT_X,
						game->currentBlockPos[1] * BLOCK_SIZE + GAME_BOARD_TOP_LEFT_Y,game->currentBlock,true);
		}

		//render the score and level display etc
		RenderHUD(game);

		//if game over, render the game over sign
		if(game->state == GAME_OVER && game->GameOverImageBool)
		{
			RenderImage(game,200,200,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->gameOverImage));
		}
	}
	else
	{
		//otherwise, we are in title screen mode, so render the main title,
		//the levels to choose from and the transparent cursor
		int xOffset = 230 + (game->Level + 4) % 5 * 35;
		int yOffset = 310 + (game->Level / 6) * 35;
		RenderImage(game,0,0,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->titleScreen));
		RenderImage(game,xOffset,yOffset,D3DXCOLOR(1.0f,1.0f,1.0f,game->transparency),&(game->cursorImg));
	}
}
コード例 #2
0
void Game::Initialize() {
    /*  Initialize ncurses  */
    if ((_mainwin = initscr()) == NULL ) {
        fprintf(stderr, "Error initializing ncurses.\n");
        exit(EXIT_FAILURE);
    }
    start_color();
    noecho();
    curs_set(0);
    RenderBoard();
    
    _userPaddle.Init(3, 10, _height, 3);
    _cpuPaddle.Init(_width-3, 10, _height, 3);
    _playing = true;
    _userScore = _cpuScore = 0;
}
コード例 #3
0
ファイル: game.cpp プロジェクト: anxkha/Breakout-3D
// ----------------------------------------------------------------------------
//  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;
}