TETRIS: use new TextRenderer interface
This commit is contained in:
+26
-27
@@ -90,15 +90,15 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( bottom_barrier );
|
||||
|
||||
auto tetris = std::make_shared< SDLPP::TextRenderer >(
|
||||
0.4, 0, 0.2, 0.1, r, *font, "TETRIS", colors["text"],
|
||||
colors["text_out"], 0.1 );
|
||||
0.4, 0, 0.2, 0.1, r, font, "TETRIS", colors["text"], colors["text_out"],
|
||||
0.1 );
|
||||
tetris->centerX();
|
||||
tetris->setStatic();
|
||||
tetris->setId( TEXT_ID );
|
||||
scene.addObject( tetris );
|
||||
|
||||
auto next = std::make_shared< SDLPP::TextRenderer >(
|
||||
RIGHT_BORDER + 0.1, 0.35, 0.2, 0.1, r, *font, "NEXT", colors["text"],
|
||||
RIGHT_BORDER + 0.1, 0.35, 0.2, 0.1, r, font, "NEXT", colors["text"],
|
||||
colors["text_out"], 0.1, SDLPP_TEXT_CENTER );
|
||||
next->centerX();
|
||||
next->setStatic();
|
||||
@@ -117,7 +117,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( gameover );
|
||||
|
||||
auto score_text = std::make_shared< SDLPP::TextRenderer >(
|
||||
RIGHT_BORDER + 0.1, 0.1, 0.2, 0.1, r, *font, "SCORE", colors["text"],
|
||||
RIGHT_BORDER + 0.1, 0.1, 0.2, 0.1, r, font, "SCORE", colors["text"],
|
||||
colors["text_out"], 0.1, SDLPP_TEXT_CENTER );
|
||||
score_text->centerX();
|
||||
score_text->setStatic();
|
||||
@@ -125,7 +125,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( score_text );
|
||||
|
||||
auto score_texture = std::make_shared< SDLPP::TextRenderer >(
|
||||
RIGHT_BORDER + 0.1, 0.2, 0.2, 0.1, r, *font, "0", colors["text"],
|
||||
RIGHT_BORDER + 0.1, 0.2, 0.2, 0.1, r, font, "0", colors["text"],
|
||||
colors["text_out"], 0.1, SDLPP_TEXT_TOP );
|
||||
score_texture->centerX();
|
||||
score_texture->setStatic();
|
||||
@@ -169,13 +169,13 @@ void addMenuSceneItems( SDLPP::Scene &scene,
|
||||
bg->setPermanent( true );
|
||||
scene.addObject( bg );
|
||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
||||
y->setText( *font, "PAUSED", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setText( font, "PAUSED", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setId( MENU_TEXT_ID );
|
||||
y->centerX();
|
||||
scene.addObject( y );
|
||||
auto resume =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.46, 0.2, 0.08, r );
|
||||
resume->setText( *font, "Resume", colors["text"], colors["text_out"], 0.1 );
|
||||
resume->setText( font, "Resume", colors["text"], colors["text_out"], 0.1 );
|
||||
resume->setColor( colors["menu_item_background"] );
|
||||
resume->centerX();
|
||||
resume->setId( MENU_ITEM_ID );
|
||||
@@ -183,21 +183,23 @@ void addMenuSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( resume );
|
||||
auto options =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.56, 0.2, 0.08, r );
|
||||
options->setText( *font, "Options", colors["text"], colors["text_out"], 0.1 );
|
||||
options->setText( font, "Options", colors["text"], colors["text_out"],
|
||||
0.1 );
|
||||
options->centerX();
|
||||
options->setId( MENU_ITEM_ID );
|
||||
g_menu_options.push_back( options );
|
||||
scene.addObject( options );
|
||||
auto restart =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.66, 0.2, 0.08, r );
|
||||
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 0.1 );
|
||||
restart->setText( font, "Restart", colors["text"], colors["text_out"],
|
||||
0.1 );
|
||||
restart->centerX();
|
||||
restart->setId( MENU_ITEM_ID );
|
||||
g_menu_options.push_back( restart );
|
||||
scene.addObject( restart );
|
||||
auto quit =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.76, 0.2, 0.08, r );
|
||||
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||
quit->setText( font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||
quit->centerX();
|
||||
quit->setId( MENU_ITEM_ID );
|
||||
g_menu_options.push_back( quit );
|
||||
@@ -213,13 +215,14 @@ void addGameOverSceneItems( SDLPP::Scene &scene,
|
||||
bg->setPermanent( true );
|
||||
scene.addObject( bg );
|
||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
||||
y->setText( *font, "GAME OVER", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setText( font, "GAME OVER", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setId( 0 );
|
||||
y->centerX();
|
||||
scene.addObject( y );
|
||||
auto restart =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.1, r );
|
||||
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 0.1 );
|
||||
restart->setText( font, "Restart", colors["text"], colors["text_out"],
|
||||
0.1 );
|
||||
restart->centerX();
|
||||
restart->setColor( colors["menu_item_background"] );
|
||||
restart->setId( MENU_ITEM_ID );
|
||||
@@ -227,7 +230,7 @@ void addGameOverSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( restart );
|
||||
auto quit =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.7, 0.2, 0.1, r );
|
||||
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||
quit->setText( font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||
quit->centerX();
|
||||
quit->setId( MENU_ITEM_ID );
|
||||
g_game_over_options.push_back( quit );
|
||||
@@ -243,14 +246,14 @@ void addOptionsSceneItems( SDLPP::Scene &scene,
|
||||
bg->setPermanent( true );
|
||||
scene.addObject( bg );
|
||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
||||
y->setText( *font, "OPTIONS", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setText( font, "OPTIONS", colors["text"], colors["text_out"], 0.1 );
|
||||
y->setId( 0 );
|
||||
y->centerX();
|
||||
scene.addObject( y );
|
||||
auto color_scheme =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.18, 0.35, 0.64, 0.09, r );
|
||||
color_scheme->setText(
|
||||
*font, "Color scheme: " + color_schemes_names[selected_color_scheme],
|
||||
font, "Color scheme: " + color_schemes_names[selected_color_scheme],
|
||||
colors["text"], colors["text_out"], 0.1 );
|
||||
color_scheme->centerX();
|
||||
color_scheme->setColor( colors["menu_item_background"] );
|
||||
@@ -259,7 +262,7 @@ void addOptionsSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( color_scheme );
|
||||
auto shadow =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.26, 0.45, 0.48, 0.09, r );
|
||||
shadow->setText( *font, "Show shadow: YES", colors["text"],
|
||||
shadow->setText( font, "Show shadow: YES", colors["text"],
|
||||
colors["text_out"], 0.1 );
|
||||
shadow->centerX();
|
||||
shadow->setId( MENU_ITEM_ID );
|
||||
@@ -267,7 +270,7 @@ void addOptionsSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( shadow );
|
||||
auto show3d =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.2, 0.55, 0.6, 0.09, r );
|
||||
show3d->setText( *font, "Show block texture: NO", colors["text"],
|
||||
show3d->setText( font, "Show block texture: NO", colors["text"],
|
||||
colors["text_out"], 0.1 );
|
||||
show3d->centerX();
|
||||
show3d->setId( MENU_ITEM_ID );
|
||||
@@ -275,7 +278,7 @@ void addOptionsSceneItems( SDLPP::Scene &scene,
|
||||
scene.addObject( show3d );
|
||||
auto save =
|
||||
std::make_shared< SDLPP::TextRenderer >( 0.42, 0.65, 0.16, 0.09, r );
|
||||
save->setText( *font, "SAVE", colors["text"], colors["text_out"], 0.1 );
|
||||
save->setText( font, "SAVE", colors["text"], colors["text_out"], 0.1 );
|
||||
save->centerX();
|
||||
save->setId( MENU_ITEM_ID );
|
||||
g_options_options.push_back( save );
|
||||
@@ -701,19 +704,17 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
break;
|
||||
case OPTIONS_MENU_SHADOW:
|
||||
g_show_shadow = !g_show_shadow;
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -725,7 +726,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
if ( selected_color_scheme == 0 )
|
||||
selected_color_scheme = color_schemes_names.size();
|
||||
selected_color_scheme--;
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_COLOR_SCHEME].get() )
|
||||
->changeText( "Color scheme: " +
|
||||
color_schemes_names[selected_color_scheme] );
|
||||
@@ -733,19 +734,17 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
break;
|
||||
case OPTIONS_MENU_SHADOW:
|
||||
g_show_shadow = !g_show_shadow;
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user