I am using Dev-C++, I am using the version of Allegro that came with Game Programming All in One. There are newer versions but he suggests not using them because there have evidently been some big changes to some commands and the programs in the book will not compile correctly.
The alternate code you just posted seems to work.
Having problems exiting from Allegro programs
Quote:Original post by Hakiko
The alternate code you just posted seems to work.
I think it may have to do with the fact that the way poll_keyboard() works. I was reading here that this function seems to be for a non Windows OS. Take a look at this quote from install_keyboard:
Quote: Note that on some platforms the keyboard won't work unless you have set a graphics mode, even if this function returns a success value before calling set_gfx_mode. This can happen in environments with graphic windowed modes, since Allegro usually reads the keyboard through the graphical window (which appears after the set_gfx_call).
So I think that was the problem.
For the code in the third post there, I'd either swap poll_keyboard() and the while loop out and put in a call to readkey(), or just type "while(! key[KEY_ESC]);". But I think you might be better served by removing that call to allegro_exit() at the end altogether as well. If nothing else, it's completely superfluous and gets called automatically when the program shuts down anyway. Try removing it and see if that cleans up the problem.
Hakiko,
I had the same problem you are having. My Allegro programs would not quit; I had to kill them manually. Even the sample program with Dev C++ would not quit correctly. Like you, I had to go into task manager and force the exe to quit.
I tried some solutions I found on Allegro.cc, but none of them helped. I finally just went ahead and removed Allegro 4.0.3 (the version giving me the problems) and switched to 4.1.18. I have not run into this issue since.
I have the same book and the samples do not work with Allegro 4.1.18. I get around this by just putting a copy of the 4.0.3 dll in the sample project's folder. The samples will run then.
Some of the commands in 4.1.18 are different, but not so much that they aren't easy to figure out. I haven't had any issues with the newer functions. Also, the documentation that comes with 4.1.18 is very well done and is very helpful.
So that would be my suggestion. Just upgrade Allegro to 4.1.18 and see if it helps the problem. You can always remove it and go back to 4.0.3 if you aren't satisfied with it.
I had the same problem you are having. My Allegro programs would not quit; I had to kill them manually. Even the sample program with Dev C++ would not quit correctly. Like you, I had to go into task manager and force the exe to quit.
I tried some solutions I found on Allegro.cc, but none of them helped. I finally just went ahead and removed Allegro 4.0.3 (the version giving me the problems) and switched to 4.1.18. I have not run into this issue since.
I have the same book and the samples do not work with Allegro 4.1.18. I get around this by just putting a copy of the 4.0.3 dll in the sample project's folder. The samples will run then.
Some of the commands in 4.1.18 are different, but not so much that they aren't easy to figure out. I haven't had any issues with the newer functions. Also, the documentation that comes with 4.1.18 is very well done and is very helpful.
So that would be my suggestion. Just upgrade Allegro to 4.1.18 and see if it helps the problem. You can always remove it and go back to 4.0.3 if you aren't satisfied with it.
I had this problem too when I first started. Remove poll_keyboard(), because you don't really need to use it in this case.
Thanks everybody
I think the problem might be the speed that it goes through the while loop. If I insert rest(10) it works with no problem at all.
I need to have a longer rest in there anyway because I am accepting mouse input for a Tic Tac Toe game and it polls the mouse button so fast without the rest that it zips through like 7 turns with one click.
So I have it working well now.
After I finish with this game I think I'll try out the other versions and stuff.
I think the problem might be the speed that it goes through the while loop. If I insert rest(10) it works with no problem at all.
I need to have a longer rest in there anyway because I am accepting mouse input for a Tic Tac Toe game and it polls the mouse button so fast without the rest that it zips through like 7 turns with one click.
So I have it working well now.
After I finish with this game I think I'll try out the other versions and stuff.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement