Application Not Responding

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
igpay
Posts: 5
Joined: Mon Oct 05, 2009 1:18 am

Application Not Responding

Post by igpay »

Hello,
I'm using irrlicht to recreate tetris, only with two games going on at the same time. Everything renders correctly, and performs as it should, but when I try to click anywhere on or outside the window, it immediately stops rendering. None of the processes the game goes through actually stop, but the window goes black. When I move my cursor over the active window, it displays a busy cursor. I believe this is preventing me from attaining user input. Is this ever a problem for anyone else?

Here is the code I believe to be causing this problem:

Code: Select all

int runGame(){
    int randum_l,randum_r;
    int elapTicks;
    float elapMilli, elapSeconds, elapMinutes;
    clock_t Begin, End;
    float since_last_l, since_last_r;
    bool controlled_l = false, controlled_r = false;
    Begin = clock() * CLK_TCK;
    randum_l = ((rand()%7)+1);
        randum_r = ((rand()%7)+1);
        switch(randum_l){
            case 1 : next_shape_l = 'i'; break;
            case 2 : next_shape_l = 'j'; break;
            case 3 : next_shape_l = 'l'; break;
            case 4 : next_shape_l = 'o'; break;
            case 5 : next_shape_l = 's'; break;
            case 6 : next_shape_l = 't'; break;
            case 7 : next_shape_l = 'z'; break;
        }
        switch(randum_r){
            case 1 : next_shape_r = 'i'; break;
            case 2 : next_shape_r = 'j'; break;
            case 3 : next_shape_r = 'l'; break;
            case 4 : next_shape_r = 'o'; break;
            case 5 : next_shape_r = 's'; break;
            case 6 : next_shape_r = 't'; break;
            case 7 : next_shape_r = 'z'; break;
        }
        spawnActive('l'); //spawns the blocks for each game
        spawnActive('r');

    while(!gameover){ //while the game isnt over, do...
        End = clock() * CLK_TCK;
        elapTicks = End - Begin;        //the number of ticks from Begin to End
        elapMilli = elapTicks/1000;     //milliseconds from Begin to End
        elapSeconds = elapMilli/1000;   //seconds from Begin to End
        since_last_l += elapSeconds;
        since_last_r += elapSeconds;
        Begin = clock() * CLK_TCK;
         if(since_last_l> 1 - (.01 * move_speed)){ //every second, the blocks move down one
                if(getMove('l','d')){
                    moveActive('l','d');
                }
                else if(!getMove('l','d')){
                    randum_l = ((rand()%7)+1);
                    switch(randum_l){
                    case 1 : next_shape_l = 'i'; break;
                    case 2 : next_shape_l = 'j'; break;
                    case 3 : next_shape_l = 'l'; break;
                    case 4 : next_shape_l = 'o'; break;
                    case 5 : next_shape_l = 's'; break;
                    case 6 : next_shape_l = 't'; break;
                    case 7 : next_shape_l = 'z'; break;
                    }
                    place('l');
                    spawnActive('l');
                }
            
            since_last_l = 0;
        }
       if(since_last_r> 1 - (.01 * move_speed)){
               if(getMove('r','d')){
                    moveActive('r','d');
                }
                else if(!getMove('r','d')){
                    randum_r = ((rand()%7)+1);
                    switch(randum_r){
                    case 1 : next_shape_r = 'i'; break;
                    case 2 : next_shape_r = 'j'; break;
                    case 3 : next_shape_r = 'l'; break;
                    case 4 : next_shape_r = 'o'; break;
                    case 5 : next_shape_r = 's'; break;
                    case 6 : next_shape_r = 't'; break;
                    case 7 : next_shape_r = 'z'; break;
                    }
                    place('r');
                    spawnActive('r');
                }
            since_last_r = 0;
        }
        
              if(!receiver.IsKeyDown(KEY_KEY_A)&&!receiver.IsKeyDown(KEY_KEY_D)){  //I'm using the event reciever from example 04 to chck for keys
            controlled_l = false;
        }
        
        if(receiver.IsKeyDown(KEY_KEY_A)&&getMove('l','l')&&!controlled_l){
            moveActive('l','l');
            controlled_l = true;
        }
        else if(receiver.IsKeyDown(KEY_KEY_D)&&getMove('l','r')&&!controlled_l){
            moveActive('l','r');
            controlled_l = true;
        }
        
        driver->beginScene(true, true, SColor(0,192,192,192)); //rendering
                
                smgr->drawAll();
                guienv->drawAll();
                
	    driver->endScene();
    }
    return 0;
}
This function is run in main() like this:

Code: Select all

device->run();
    
    runGame();
 
    device->drop();
I hope that was understandable enough...
Thanks in advance.
igpay
Posts: 5
Joined: Mon Oct 05, 2009 1:18 am

Post by igpay »

I'm actually not sure what the problem is anymore, is the way I am checking for input even correct?
CuteAlien
Admin
Posts: 10035
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I think you didn't post the line which is responsible here. It sounds like you have a isWindowActive() check in your main-loop (most examples have that).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply