Page 1 of 1

game crashes when while loop used

Posted: Sat Mar 18, 2006 4:24 pm
by Guest
whenever i use a while loop the game crashes, BTW i am using Irrlicht....

I tried everthing, i don't understand why it crashes....

maybe i have to add someting when i use while loop... so if any1 knows how to implement a correct while loop to LOOp obviously when useing Irrlicht engine

Thanks

Posted: Sat Mar 18, 2006 5:00 pm
by JP
What are you using the while loop for?

If you're not using threads and stick a while loop in your code then it will halt the engine from rendering until the loop is finished.

Posted: Sat Mar 18, 2006 5:24 pm
by killzone721
what are threads and stick

you are correct that the while loop does halt the engine... i think stops the main loop:
driver->beginScene(...);
driver->end scene();

i am using a while loop for the timer... actually to jump

/////////////////////////////////////////////////////////////
while(now!=time that was set)
{
driver->beginScene(...); // i think this helps the engine to do on
jump;
reverse gravity
driver->end scene();
}
stop jump
put gravuty back on
///////////////////////////////////////////////

BUT IT STILL CARSHES

am i missing something
thanks

Posted: Sat Mar 18, 2006 5:41 pm
by JP
Does it actually crash or just halt the program?

Because it seems that that would just stop everything until the time comes along, and the while loop will just stop EVERYTHING from happening, no rendering will be done, because everything's carried out sequentially.

You either need to introduce threads (allowing concurrent execution of different bits of code) or in the while(device->run()) loop do a check to see if the time has arrived, but not using a while loop.

Posted: Sat Mar 18, 2006 6:06 pm
by Guest = killzone721
well it just stops... but it doesn't work again.... actually the program doesn't respond anymore completely even after the time given in the while loop, it just doesn't respond anymore and i am force to ctrl + alt + del to end task the exe...

so i am not sure what to call it except crash

idea about check the time in the main loop... i tried that but it doesn't work for me and it makes the program extremely laggy...

i will keep on trying... and please keep on giving me ideas

THANKS