Sign in to follow this  

allegro program close error

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this