TETRIS: use updated TextRenderer
This commit is contained in:
parent
7267cb7b9a
commit
67a56d31de
@ -52,13 +52,16 @@ functions.${OBJEXT}: functions.cpp config.hpp functions.hpp global_vars.hpp scen
|
|||||||
global_vars.${OBJEXT}: global_vars.cpp config.hpp global_vars.hpp functions.hpp
|
global_vars.${OBJEXT}: global_vars.cpp config.hpp global_vars.hpp functions.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
$(CXX) $(CXXFLAGS) -c ${OUTPUTFLAG}$@ $<
|
||||||
libsdlpp.so: ../sdlpp
|
libsdlpp.so: ../sdlpp
|
||||||
|
$(MAKE) clean -C ../sdlpp
|
||||||
$(MAKE) -C ../sdlpp
|
$(MAKE) -C ../sdlpp
|
||||||
cp ../sdlpp/libsdlpp.so .
|
cp ../sdlpp/libsdlpp.so .
|
||||||
ln -sf libsdlpp.so libsdlpp.so.1
|
ln -sf libsdlpp.so libsdlpp.so.1
|
||||||
libsdlpp.dylib: ../sdlpp
|
libsdlpp.dylib: ../sdlpp
|
||||||
|
$(MAKE) clean -C ../sdlpp
|
||||||
$(MAKE) -C ../sdlpp
|
$(MAKE) -C ../sdlpp
|
||||||
cp ../sdlpp/libsdlpp.dylib .
|
cp ../sdlpp/libsdlpp.dylib .
|
||||||
libsdlpp.dll: ../sdlpp
|
libsdlpp.dll: ../sdlpp
|
||||||
|
$(MAKE) clean -C ../sdlpp
|
||||||
$(MAKE) -C ../sdlpp
|
$(MAKE) -C ../sdlpp
|
||||||
cp ../sdlpp/libsdlpp.dll .
|
cp ../sdlpp/libsdlpp.dll .
|
||||||
cp ../sdlpp/libsdlpp.lib .
|
cp ../sdlpp/libsdlpp.lib .
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
#define BARRIER_ID 0x0000000B
|
#define BARRIER_ID 0x0000000B
|
||||||
#define TEXT_ID 0x0000000C
|
#define TEXT_ID 0x0000000C
|
||||||
|
|
||||||
#define MENU_ITEM_ID 0x00000001
|
#define MENU_ITEM_ID 0x10000001
|
||||||
#define MENU_BACKGROUND_ID 0x00000002
|
#define MENU_BACKGROUND_ID 0x10000002
|
||||||
#define MENU_TEXT_ID 0x00000003
|
#define MENU_TEXT_ID 0x10000003
|
||||||
|
|
||||||
#define LEFT_BORDER 0.3
|
#define LEFT_BORDER 0.3
|
||||||
#define RIGHT_BORDER 0.7
|
#define RIGHT_BORDER 0.7
|
||||||
|
@ -390,6 +390,36 @@ tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
|||||||
return retPiece;
|
return retPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateTextSizeInternal(std::shared_ptr<SDLPP::RenderObject> input) {
|
||||||
|
if(input->getKilled())
|
||||||
|
return;
|
||||||
|
std::dynamic_pointer_cast< SDLPP::TextRenderer >( input )->setTextColor(
|
||||||
|
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateSize() {
|
||||||
|
// have to resize rectangles for the text to be resized correctly
|
||||||
|
g_main_scene->updateSizeAndPosition();
|
||||||
|
g_menu_scene->updateSizeAndPosition();
|
||||||
|
g_game_over_scene->updateSizeAndPosition();
|
||||||
|
g_options_scene->updateSizeAndPosition();
|
||||||
|
|
||||||
|
std::unordered_set<int> textObjects = { TEXT_ID, MENU_TEXT_ID, MENU_ITEM_ID };
|
||||||
|
for( auto &x : g_main_scene->getObjects( textObjects ) ) {
|
||||||
|
updateTextSizeInternal(x);
|
||||||
|
}
|
||||||
|
updateTextSizeInternal(g_score_texture);
|
||||||
|
for( auto &x : g_menu_scene->getObjects( textObjects ) ) {
|
||||||
|
updateTextSizeInternal(x);
|
||||||
|
}
|
||||||
|
for( auto &x : g_game_over_scene->getObjects( textObjects ) ) {
|
||||||
|
updateTextSizeInternal(x);
|
||||||
|
}
|
||||||
|
for( auto &x : g_options_scene->getObjects( textObjects ) ) {
|
||||||
|
updateTextSizeInternal(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateColors() {
|
void updateColors() {
|
||||||
for ( auto &x : g_main_scene->getObjects( { BRICK_ID, SHADOW_ID } ) ) {
|
for ( auto &x : g_main_scene->getObjects( { BRICK_ID, SHADOW_ID } ) ) {
|
||||||
x->specialAction( PIECE_ACTION_UPDATE_COLOR );
|
x->specialAction( PIECE_ACTION_UPDATE_COLOR );
|
||||||
@ -408,7 +438,7 @@ void updateColors() {
|
|||||||
}
|
}
|
||||||
for ( auto &x : g_main_scene->getObjects( { TEXT_ID } ) ) {
|
for ( auto &x : g_main_scene->getObjects( { TEXT_ID } ) ) {
|
||||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
||||||
*g_font, colors["text"], colors["text_out"], 5 );
|
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||||
}
|
}
|
||||||
g_menu_options[g_menu_select]->setColor( colors["menu_item_background"] );
|
g_menu_options[g_menu_select]->setColor( colors["menu_item_background"] );
|
||||||
g_game_over_options[g_game_over_select]->setColor(
|
g_game_over_options[g_game_over_select]->setColor(
|
||||||
@ -424,8 +454,5 @@ void updateColors() {
|
|||||||
for ( auto &x : g_options_scene->getObjects( { MENU_BACKGROUND_ID } ) ) {
|
for ( auto &x : g_options_scene->getObjects( { MENU_BACKGROUND_ID } ) ) {
|
||||||
x->setColor( colors["menu_background"] );
|
x->setColor( colors["menu_background"] );
|
||||||
}
|
}
|
||||||
for ( auto &x : g_options_scene->getObjects( { MENU_ITEM_ID } ) ) {
|
updateSize();
|
||||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
|
||||||
*g_font, colors["text"], colors["text_out"] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -33,5 +33,6 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene );
|
std::shared_ptr< SDLPP::Scene > scene );
|
||||||
void updateColors();
|
void updateColors();
|
||||||
|
void updateSize();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,7 @@ bool g_update_score = false;
|
|||||||
bool g_update_colors = false;
|
bool g_update_colors = false;
|
||||||
bool g_checked_line = false;
|
bool g_checked_line = false;
|
||||||
bool g_wait_for_anim = false;
|
bool g_wait_for_anim = false;
|
||||||
|
bool g_update_size = false;
|
||||||
|
|
||||||
std::vector< int > g_bag = { 28, 28, 28, 28, 28, 28, 28 };
|
std::vector< int > g_bag = { 28, 28, 28, 28, 28, 28, 28 };
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ extern bool g_update_score;
|
|||||||
extern bool g_update_colors;
|
extern bool g_update_colors;
|
||||||
extern bool g_checked_line;
|
extern bool g_checked_line;
|
||||||
extern bool g_wait_for_anim;
|
extern bool g_wait_for_anim;
|
||||||
|
extern bool g_update_size;
|
||||||
|
|
||||||
extern std::vector< int > g_bag;
|
extern std::vector< int > g_bag;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
|||||||
|
|
||||||
auto tetris = std::make_shared< SDLPP::TextRenderer >(
|
auto tetris = std::make_shared< SDLPP::TextRenderer >(
|
||||||
0.4, 0, 0.2, 0.1, r, *font, "TETRIS", colors["text"],
|
0.4, 0, 0.2, 0.1, r, *font, "TETRIS", colors["text"],
|
||||||
colors["text_out"], 5 );
|
colors["text_out"], 0.1 );
|
||||||
tetris->centerX();
|
tetris->centerX();
|
||||||
tetris->setStatic();
|
tetris->setStatic();
|
||||||
tetris->setId( TEXT_ID );
|
tetris->setId( TEXT_ID );
|
||||||
@ -99,7 +99,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
|||||||
|
|
||||||
auto next = std::make_shared< SDLPP::TextRenderer >(
|
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"], 5, SDLPP_TEXT_CENTER );
|
colors["text_out"], 0.1, SDLPP_TEXT_CENTER );
|
||||||
next->centerX();
|
next->centerX();
|
||||||
next->setStatic();
|
next->setStatic();
|
||||||
next->setId( TEXT_ID );
|
next->setId( TEXT_ID );
|
||||||
@ -118,7 +118,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
|||||||
|
|
||||||
auto score_text = std::make_shared< SDLPP::TextRenderer >(
|
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"], 5, SDLPP_TEXT_CENTER );
|
colors["text_out"], 0.1, SDLPP_TEXT_CENTER );
|
||||||
score_text->centerX();
|
score_text->centerX();
|
||||||
score_text->setStatic();
|
score_text->setStatic();
|
||||||
score_text->setId( TEXT_ID );
|
score_text->setId( TEXT_ID );
|
||||||
@ -126,7 +126,7 @@ void addMainSceneItems( SDLPP::Scene &scene,
|
|||||||
|
|
||||||
auto score_texture = std::make_shared< SDLPP::TextRenderer >(
|
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"], 5, SDLPP_TEXT_TOP );
|
colors["text_out"], 0.1, SDLPP_TEXT_TOP );
|
||||||
score_texture->centerX();
|
score_texture->centerX();
|
||||||
score_texture->setStatic();
|
score_texture->setStatic();
|
||||||
score_texture->setId( SCORE_TEXTURE_ID );
|
score_texture->setId( SCORE_TEXTURE_ID );
|
||||||
@ -169,13 +169,13 @@ void addMenuSceneItems( SDLPP::Scene &scene,
|
|||||||
bg->setPermanent( true );
|
bg->setPermanent( true );
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
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"], 5 );
|
y->setText( *font, "PAUSED", colors["text"], colors["text_out"], 0.1 );
|
||||||
y->setId( MENU_TEXT_ID );
|
y->setId( MENU_TEXT_ID );
|
||||||
y->centerX();
|
y->centerX();
|
||||||
scene.addObject( y );
|
scene.addObject( y );
|
||||||
auto resume =
|
auto resume =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.46, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.46, 0.2, 0.08, r );
|
||||||
resume->setText( *font, "Resume", colors["text"], colors["text_out"], 5 );
|
resume->setText( *font, "Resume", colors["text"], colors["text_out"], 0.1 );
|
||||||
resume->setColor( colors["menu_item_background"] );
|
resume->setColor( colors["menu_item_background"] );
|
||||||
resume->centerX();
|
resume->centerX();
|
||||||
resume->setId( MENU_ITEM_ID );
|
resume->setId( MENU_ITEM_ID );
|
||||||
@ -183,21 +183,21 @@ void addMenuSceneItems( SDLPP::Scene &scene,
|
|||||||
scene.addObject( resume );
|
scene.addObject( resume );
|
||||||
auto options =
|
auto options =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.56, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.56, 0.2, 0.08, r );
|
||||||
options->setText( *font, "Options", colors["text"], colors["text_out"], 5 );
|
options->setText( *font, "Options", colors["text"], colors["text_out"], 0.1 );
|
||||||
options->centerX();
|
options->centerX();
|
||||||
options->setId( MENU_ITEM_ID );
|
options->setId( MENU_ITEM_ID );
|
||||||
g_menu_options.push_back( options );
|
g_menu_options.push_back( options );
|
||||||
scene.addObject( options );
|
scene.addObject( options );
|
||||||
auto restart =
|
auto restart =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.66, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.66, 0.2, 0.08, r );
|
||||||
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 5 );
|
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 0.1 );
|
||||||
restart->centerX();
|
restart->centerX();
|
||||||
restart->setId( MENU_ITEM_ID );
|
restart->setId( MENU_ITEM_ID );
|
||||||
g_menu_options.push_back( restart );
|
g_menu_options.push_back( restart );
|
||||||
scene.addObject( restart );
|
scene.addObject( restart );
|
||||||
auto quit =
|
auto quit =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.76, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.76, 0.2, 0.08, r );
|
||||||
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 5 );
|
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||||
quit->centerX();
|
quit->centerX();
|
||||||
quit->setId( MENU_ITEM_ID );
|
quit->setId( MENU_ITEM_ID );
|
||||||
g_menu_options.push_back( quit );
|
g_menu_options.push_back( quit );
|
||||||
@ -213,13 +213,13 @@ void addGameOverSceneItems( SDLPP::Scene &scene,
|
|||||||
bg->setPermanent( true );
|
bg->setPermanent( true );
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
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"], 5 );
|
y->setText( *font, "GAME OVER", colors["text"], colors["text_out"], 0.1 );
|
||||||
y->setId( 0 );
|
y->setId( 0 );
|
||||||
y->centerX();
|
y->centerX();
|
||||||
scene.addObject( y );
|
scene.addObject( y );
|
||||||
auto restart =
|
auto restart =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.1, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.1, r );
|
||||||
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 5 );
|
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 0.1 );
|
||||||
restart->centerX();
|
restart->centerX();
|
||||||
restart->setColor( colors["menu_item_background"] );
|
restart->setColor( colors["menu_item_background"] );
|
||||||
restart->setId( MENU_ITEM_ID );
|
restart->setId( MENU_ITEM_ID );
|
||||||
@ -227,7 +227,7 @@ void addGameOverSceneItems( SDLPP::Scene &scene,
|
|||||||
scene.addObject( restart );
|
scene.addObject( restart );
|
||||||
auto quit =
|
auto quit =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.7, 0.2, 0.1, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.7, 0.2, 0.1, r );
|
||||||
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 5 );
|
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 0.1 );
|
||||||
quit->centerX();
|
quit->centerX();
|
||||||
quit->setId( MENU_ITEM_ID );
|
quit->setId( MENU_ITEM_ID );
|
||||||
g_game_over_options.push_back( quit );
|
g_game_over_options.push_back( quit );
|
||||||
@ -243,39 +243,39 @@ void addOptionsSceneItems( SDLPP::Scene &scene,
|
|||||||
bg->setPermanent( true );
|
bg->setPermanent( true );
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
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"], 5 );
|
y->setText( *font, "OPTIONS", colors["text"], colors["text_out"], 0.1 );
|
||||||
y->setId( 0 );
|
y->setId( 0 );
|
||||||
y->centerX();
|
y->centerX();
|
||||||
scene.addObject( y );
|
scene.addObject( y );
|
||||||
auto color_scheme =
|
auto color_scheme =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.35, 0.3, 0.3, 0.09, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.18, 0.35, 0.64, 0.09, r );
|
||||||
color_scheme->setText(
|
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"], 5 );
|
colors["text"], colors["text_out"], 0.1 );
|
||||||
color_scheme->centerX();
|
color_scheme->centerX();
|
||||||
color_scheme->setColor( colors["menu_item_background"] );
|
color_scheme->setColor( colors["menu_item_background"] );
|
||||||
color_scheme->setId( MENU_ITEM_ID );
|
color_scheme->setId( MENU_ITEM_ID );
|
||||||
g_options_options.push_back( color_scheme );
|
g_options_options.push_back( color_scheme );
|
||||||
scene.addObject( color_scheme );
|
scene.addObject( color_scheme );
|
||||||
auto shadow =
|
auto shadow =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.4, 0.2, 0.09, r );
|
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"], 5 );
|
colors["text_out"], 0.1 );
|
||||||
shadow->centerX();
|
shadow->centerX();
|
||||||
shadow->setId( MENU_ITEM_ID );
|
shadow->setId( MENU_ITEM_ID );
|
||||||
g_options_options.push_back( shadow );
|
g_options_options.push_back( shadow );
|
||||||
scene.addObject( shadow );
|
scene.addObject( shadow );
|
||||||
auto show3d =
|
auto show3d =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.09, r );
|
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"], 5 );
|
colors["text_out"], 0.1 );
|
||||||
show3d->centerX();
|
show3d->centerX();
|
||||||
show3d->setId( MENU_ITEM_ID );
|
show3d->setId( MENU_ITEM_ID );
|
||||||
g_options_options.push_back( show3d );
|
g_options_options.push_back( show3d );
|
||||||
scene.addObject( show3d );
|
scene.addObject( show3d );
|
||||||
auto save =
|
auto save =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.45, 0.6, 0.1, 0.09, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.42, 0.65, 0.16, 0.09, r );
|
||||||
save->setText( *font, "SAVE", colors["text"], colors["text_out"], 5 );
|
save->setText( *font, "SAVE", colors["text"], colors["text_out"], 0.1 );
|
||||||
save->centerX();
|
save->centerX();
|
||||||
save->setId( MENU_ITEM_ID );
|
save->setId( MENU_ITEM_ID );
|
||||||
g_options_options.push_back( save );
|
g_options_options.push_back( save );
|
||||||
@ -434,6 +434,7 @@ void pollEventsMain( SDLPP::Scene &scene ) {
|
|||||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||||
for ( auto &x : g_active_scenes )
|
for ( auto &x : g_active_scenes )
|
||||||
x->updateSizeAndPosition();
|
x->updateSizeAndPosition();
|
||||||
|
g_update_size = true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -565,6 +566,7 @@ void pollEventsMenu() {
|
|||||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||||
for ( auto &x : g_active_scenes )
|
for ( auto &x : g_active_scenes )
|
||||||
x->updateSizeAndPosition();
|
x->updateSizeAndPosition();
|
||||||
|
g_update_size = true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -635,6 +637,7 @@ void pollEventsGameOver() {
|
|||||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||||
for ( auto &x : g_active_scenes )
|
for ( auto &x : g_active_scenes )
|
||||||
x->updateSizeAndPosition();
|
x->updateSizeAndPosition();
|
||||||
|
g_update_size = true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -782,6 +785,7 @@ void pollEventsOptions() {
|
|||||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||||
for ( auto &x : g_active_scenes )
|
for ( auto &x : g_active_scenes )
|
||||||
x->updateSizeAndPosition();
|
x->updateSizeAndPosition();
|
||||||
|
g_update_size = true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -20,7 +20,7 @@ std::vector< std::shared_ptr< SDLPP::RenderObject > > line_coliders{};
|
|||||||
|
|
||||||
void updateScore( std::shared_ptr< SDLPP::Font > font ) {
|
void updateScore( std::shared_ptr< SDLPP::Font > font ) {
|
||||||
g_score_texture->setText( *font, std::to_string( g_score ), colors["text"],
|
g_score_texture->setText( *font, std::to_string( g_score ), colors["text"],
|
||||||
colors["text_out"], 5 );
|
colors["text_out"], 0.1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void doInput() {
|
void doInput() {
|
||||||
@ -138,6 +138,10 @@ int main() {
|
|||||||
updateColors();
|
updateColors();
|
||||||
g_update_colors = false;
|
g_update_colors = false;
|
||||||
}
|
}
|
||||||
|
if ( g_update_size ) {
|
||||||
|
updateSize();
|
||||||
|
g_update_size = false;
|
||||||
|
}
|
||||||
|
|
||||||
renderer->clearRenderer();
|
renderer->clearRenderer();
|
||||||
for ( auto &x : g_active_scenes ) {
|
for ( auto &x : g_active_scenes ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user