Tetris: move generating of new blocks after restart to main thread
This commit is contained in:
parent
96c54454f7
commit
883ad19a50
@ -121,10 +121,6 @@ void resetGame() {
|
||||
g_main_scene->setPrevTicks( SDL_GetTicks() );
|
||||
|
||||
// TODO maybe move to main thread
|
||||
g_next_object = g_tetrisFunctions[std::rand() / ( ( RAND_MAX + 1u ) / 7 )](
|
||||
g_main_scene->getRendererShared(), g_main_scene );
|
||||
g_next_object->setPos( 0.9, 0.5 );
|
||||
g_active_scenes.push_back( g_main_scene );
|
||||
g_active_scenes = {g_main_scene};
|
||||
g_input_functions = {mainSceneInput};
|
||||
for(int i = 0; i < 7; i++)
|
||||
|
@ -89,6 +89,11 @@ int main() {
|
||||
SDL_framerateDelay( &gFPS );
|
||||
if ( !g_cur_object && g_checked_line ) {
|
||||
std::lock_guard< std::mutex > guard( g_movement_mutex );
|
||||
if ( !g_next_object ) {
|
||||
g_next_object = g_tetrisFunctions[std::rand() / ( ( RAND_MAX + 1u ) / 7 )](
|
||||
g_main_scene->getRendererShared(), g_main_scene );
|
||||
g_next_object->setPos( 0.9, 0.5 );
|
||||
}
|
||||
|
||||
g_cur_object = g_next_object;
|
||||
g_cur_object->setPos( 0.5, TOP_BORDER - BLOCK_SIZE );
|
||||
|
Loading…
Reference in New Issue
Block a user