I want to make board game - I wrote use library allegro to displaying board . But what to do to display in a window, because now it is display without window so I must push ESC to close this programm ? What should I do ?
PS. I want write this game in C ++, but code library allegro is very different from c++ :/
| 1 | #include <allegro.h> |
| 2 | #include<iostream> |
| 3 | #include<ctime> |
| 4 | #include<cstring> |
| 5 | using namespace std; |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | BITMAP *rysunek = NULL; |
| 13 | |
| 14 | allegro_init(); |
| 15 | install_keyboard(); |
| 16 | set_color_depth(16); |
| 17 | set_gfx_mode(GFX_AUTODETECT,1024,768,0,0); |
| 18 | clear_to_color(screen,15); |
| 19 | |
| 20 | rysunek = load_bitmap("cos.bmp",default_palette); |
| 21 | blit(rysunek,screen,0,0,0,0,rysunek->w,rysunek->h); |
| 22 | |
| 23 | |
| 24 | readkey(); |
| 25 | allegro_exit(); |
| 26 | return 0; |
| 27 | } |
| 28 | END_OF_MAIN() |
Try
set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0);
Make sure the resolution is smaller than desktop's. But still I'm not sure wheter you will be able to close it with X button.
But still I'm not sure wheter you will be able to close it with X button.
You need to install a callback for the close button. See the manual for more details.
install callback
could you give me a link ?
And why allegro is so different from c++ ??
Allegro is not any different than C++ because allegro is a library for C++ (Or C, depending on how you program.)
I am interested in the close button as well.
install callback
could you give me a link ?
set_close_button_callback( my_close_function );
The forum parser isnt recognizing that function so heres the link to the manual
http://alleg.sourceforge.net/stabledocs/en/alleg000.html#set_close_button_callback
And why allegro is so different from c++ ??
Allegro is very different from C++. Allegro is a library, C++ is a language.