Game Development Reference
In-Depth Information
10. The next igure is rendered near the control buttons, as shown in the
following screenshot:
11. The code is more complicated, since we need to evaluate the bounding box of the
shape to render it properly:
int Cx1, Cy1, Cx2, Cy2;
g_NextFigure.GetTopLeftCorner(&Cx1, &Cy1 );
g_NextFigure.GetBottomRightCorner(&Cx2, &Cy2 );
LRect FigureSize = g_NextFigure.GetSize();
float dX = ( float )Cx1 * BLOCK_SIZE_SMALL / 800.0f;
float dY = ( float )Cy1 * BLOCK_SIZE_SMALL / 600.0f;
float dX2 = 0.5f * (float)Cx2 * BLOCK_SIZE_SMALL/800.0f;
float dY2 = 0.5f * (float)Cy2 * BLOCK_SIZE_SMALL/600.0f;
DrawFigure( &g_NextFigure, 0, 0, 0.415f - dX - dX2,
0.77f - dY - dY2, BLOCK_SIZE_SMALL );
12. Render the current score text, as shown in the following screenshot:
13. Once the text changes, it is rendered into a bitmap, and the texture is updated:
std::string ScoreString( Str_GetFormatted( "%02i:%06i",
g_GS.FLevel, g_GS.FScore ) );
if ( g_ScoreText != ScoreString )
{
g_ScoreText = ScoreString;
g_ScoreBitmap = g_TextRenderer->RenderTextWithFont(
ScoreString.c_str(), g_Font,32, 0xFFFFFFFF, true );
g_ScoreTexture->LoadFromBitmap( g_ScoreBitmap );
}
 
Search WWH ::




Custom Search