TETRIS: Fix restart
This commit is contained in:
parent
594316dcea
commit
406186d8bb
@ -118,6 +118,8 @@ void quitGame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetGame() {
|
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_cur_object.reset();
|
||||||
g_checked_line = true;
|
g_checked_line = true;
|
||||||
g_next_object.reset();
|
g_next_object.reset();
|
||||||
|
@ -36,6 +36,7 @@ std::shared_ptr< TetrisPiece > g_cur_shadow{};
|
|||||||
std::shared_ptr< SDLPP::RectangleRender > g_shadow_colider{};
|
std::shared_ptr< SDLPP::RectangleRender > g_shadow_colider{};
|
||||||
|
|
||||||
std::mutex g_movement_mutex{};
|
std::mutex g_movement_mutex{};
|
||||||
|
std::mutex g_render_mutex{};
|
||||||
|
|
||||||
bool g_quit = false;
|
bool g_quit = false;
|
||||||
std::vector< std::function< void(
|
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::shared_ptr< SDLPP::RectangleRender > g_shadow_colider;
|
||||||
|
|
||||||
extern std::mutex g_movement_mutex;
|
extern std::mutex g_movement_mutex;
|
||||||
|
extern std::mutex g_render_mutex;
|
||||||
|
|
||||||
extern bool g_quit;
|
extern bool g_quit;
|
||||||
extern std::vector< std::function< void(
|
extern std::vector< std::function< void(
|
||||||
|
@ -157,12 +157,15 @@ int main() {
|
|||||||
g_update_objects.pop_back();
|
g_update_objects.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard< std::mutex > guard( g_render_mutex );
|
||||||
renderer->clearRenderer();
|
renderer->clearRenderer();
|
||||||
for ( size_t i = 0; i < g_active_scenes.size(); i++ ) {
|
for ( size_t i = 0; i < g_active_scenes.size(); i++ ) {
|
||||||
g_active_scenes[i]->updateScene();
|
g_active_scenes[i]->updateScene();
|
||||||
g_active_scenes[i]->renderScene( false );
|
g_active_scenes[i]->renderScene( false );
|
||||||
}
|
}
|
||||||
renderer->presentRenderer();
|
renderer->presentRenderer();
|
||||||
|
}
|
||||||
g_wait_for_anim = false;
|
g_wait_for_anim = false;
|
||||||
frames++;
|
frames++;
|
||||||
if ( SDL_GetTicks() - base >= 1000 ) {
|
if ( SDL_GetTicks() - base >= 1000 ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user