TETRIS: Fix restart

This commit is contained in:
zvon 2021-03-14 17:02:41 +01:00
parent 594316dcea
commit 406186d8bb
4 changed files with 12 additions and 5 deletions

View File

@ -118,6 +118,8 @@ void quitGame() {
}
void resetGame() {
std::lock_guard< std::mutex > guard( g_render_mutex );
std::lock_guard< std::mutex > guard2( g_movement_mutex );
g_cur_object.reset();
g_checked_line = true;
g_next_object.reset();

View File

@ -36,6 +36,7 @@ std::shared_ptr< TetrisPiece > g_cur_shadow{};
std::shared_ptr< SDLPP::RectangleRender > g_shadow_colider{};
std::mutex g_movement_mutex{};
std::mutex g_render_mutex{};
bool g_quit = false;
std::vector< std::function< void(

View File

@ -42,6 +42,7 @@ extern std::shared_ptr< TetrisPiece > g_cur_shadow;
extern std::shared_ptr< SDLPP::RectangleRender > g_shadow_colider;
extern std::mutex g_movement_mutex;
extern std::mutex g_render_mutex;
extern bool g_quit;
extern std::vector< std::function< void(

View File

@ -157,12 +157,15 @@ int main() {
g_update_objects.pop_back();
}
{
std::lock_guard< std::mutex > guard( g_render_mutex );
renderer->clearRenderer();
for ( size_t i = 0; i < g_active_scenes.size(); i++ ) {
g_active_scenes[i]->updateScene();
g_active_scenes[i]->renderScene( false );
}
renderer->presentRenderer();
}
g_wait_for_anim = false;
frames++;
if ( SDL_GetTicks() - base >= 1000 ) {