Advertisement Jump to content
Sign in to follow this  

allegro program close error

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the problem im having is when you press escape , the game loop does end , but the program keep running and i dont know how to get it to make the program close.

ofstream fout;

BITMAP* buffer;
BITMAP* ball;
BITMAP* pdle_1;
BITMAP* pdle_2;

int ticks  = 0;
const int FPS = 30;

void ticker()

int main(void)
	set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	buffer = create_bitmap(640, 480);

	pdle_1 = load_bitmap("images/paddle.bmp",NULL);
	pdle_2 = load_bitmap("images/paddle.bmp",NULL);
	ball   = load_bitmap("images/ball.bmp",NULL);
	int frames = ticks;
    install_int_ex(ticker, BPS_TO_TIMER(FPS));
	while( !key[KEY_ESC])
	    if (frames % 2 == 0)
			masked_blit(ball,buffer, 0, 0, 0, 0, 30,30);
			blit(buffer, screen, 0, 0, 0, 0, 640, 480);
	allegro_message("exited loop");

	return 0;


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Put allegro_exit after main.

the way it is, the loop ends, but allegro_exit is never called.

Share this post

Link to post
Share on other sites
By calling allegro_init() allegro will automatically call allegro_exit() upon termination of the main game loop. I think what you need to do is destroy all of your bitmaps, not just the buffer bitmap. Not too sure though, I haven't allegro since about 10th grade(approx. 5 yrs). Hope that helps.


Share this post

Link to post
Share on other sites
Let me see: the loop terminates (as notified by the allegro_message("exited loop"); ), but the program does not exit (either the window is still visible, or the program process is still running).

If the symptoms are like that, then you've encountered an Allegro bug plaguing some the WIPs and the earlier betas. It is a known bug (some thread race condition) that appears in some configurations, and as far as I remember has been corrected. Check if using the latest Allegro version (4.2.0 stable) corrects the problem. If it does not, please report this here, especially if you have a dual core system.

EDIT: also, try marking the ticks variable as volatile, so it won't be touched by the compiler.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!