TETRIS: Fix restart
This commit is contained in:
parent
594316dcea
commit
406186d8bb
@ -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();
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user