Jump to content
  • Advertisement
Sign in to follow this  
Acid rain

Exiting the game

This topic is 4448 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

When you use the allegro library to write a game, normally you would have SPRITES, BITMAPS, SAMPLES, etc. Now when you first write the code to declare these it crates them in memory. Now to exit the game you have to destroy every thing you created so it doesn't kill your comps memory. For all of my games, I use the key ESC to trigger this, but if you have a windowed game with the X buttun on the top right, how do you use that to exit the program SUCCESSFULLY?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Acid rain
I don't get the code. Shouldn't there be an 'if' statement to detect the press?


No, it just sets your uninitialization code as an automated call (in response to WM_QUIT or something like that) when the program exits.

Share this post


Link to post
Share on other sites
So the function checks automatically when you call if? And if the key is pressed, it excecutes the function code?

Share this post


Link to post
Share on other sites
Quote:
Original post by Acid rain
So the function checks automatically when you call if? And if the key is pressed, it excecutes the function code?

It just automatically calls the function when the program ends. How the program ends isn't relevant.

Share this post


Link to post
Share on other sites
Quote:
Original post by Acid rain
So the function checks automatically when you call if? And if the key is pressed, it excecutes the function code?


It calls the funtion pointed to by "void (*proc)(void)". It's a function pointer, a pointer to the function you've written to do all your shutdown code. This function is called when the 'X' button on the top right is pressed.

Share this post


Link to post
Share on other sites
Quote:

Now to exit the game you have to destroy every thing you created so it doesn't kill your comps memory.


When a program exits, all memory should be automatically reclaimed by the operating system... or are you using an OS (if there is one) for which you know this is not the case?

Share this post


Link to post
Share on other sites
No, I am using a Windows. But using allegro, you have to make calls to a function to reclaim the memory.
The Destroy_"DATA TYPE"();

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Acid rain
Now to exit the game you have to destroy every thing you created so it doesn't kill your comps memory.


Are you still running Windows 3.1? LOL


Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!