maciek1316 Temat założony przez niniejszego użytkownika |
[Allegro] Wystąpił problem z aplikacją Projekt1.exe i zostanie ona zamknięta. » 2008-05-16 18:14:43 Tak to znowu ja... Program działa, kompilacja przechodzi pomyślnie tylko w grze błędy wyskakują. Klasyczne windowsowski "Wystąpił problem z aplikacją Projekt1.exe i zostanie ona zamknięta. Przepraszamy za kłopoty. itd" Wyskakuje podczas zamykania programu przy przyciśnięciu ESC i Q. Dlaczego tak się dzieje? Już mnie to denerwuje cały czas błędy... Piotrze pomóż:D #include <allegro.h> int mx = 0, my = 0, mb = 0; void myszka() { if( mx != mouse_x || my != mouse_y || mb != mouse_b ) { mx = mouse_x; my = mouse_y; mb = mouse_b; } };
void Gra( BITMAP * bufor, int maxx, int maxy ) { int x = 250, y = 150; int x1 = 250, y1 = 550; int a; a = 1; bool kolizja = false; BITMAP * tlo = NULL; tlo = load_bmp( "tlo.bmp", default_palette ); do { if(( key[ KEY_UP ] ) &&( x > 20 ) ) x = x - 2; if(( key[ KEY_DOWN ] ) &&( x < 780 ) ) x = x + 2; if(( key[ KEY_LEFT ] ) &&( y > 20 ) ) y = y - 2; if(( key[ KEY_RIGHT ] ) &&( y < 780 ) ) y = y + 2; if( key[ KEY_W ] ) x1--; if( key[ KEY_S ] ) x1++; if( key[ KEY_A ] ) y1--; if( key[ KEY_D ] ) y1++; clear_to_color( bufor, makecol( 46, 54, 140 ) ); blit( tlo, bufor, 0, 0, 0, 0, tlo->w, tlo->h ); rectfill( bufor, y1, x1, y1 + 50, x1 + 50, makecol( 0, 0, 0 ) ); rectfill( bufor, y, x, y + 50, x + 50, makecol( 255, 255, 255 ) ); if(( x == x1 + 50 ) &&( y <= y1 + 50 ) &&( y + 50 >= y1 ) ) kolizja = true; if(( x + 50 == x1 ) &&( y <= y1 + 50 ) &&( y + 50 >= y1 ) ) kolizja = true; if(( y + 50 == y1 ) &&( x <= x1 + 50 ) &&( x + 50 >= x1 ) ) kolizja = true; if(( y == y1 + 50 ) &&( x <= x1 + 50 ) &&( x + 50 >= x1 ) ) kolizja = true; blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); if( kolizja == true ) { BITMAP * koniec = NULL; koniec = load_bmp( "koniec.bmp", default_palette ); blit( koniec, screen, 0, 0, 300, 200, 300, 200 ); if( !key[ KEY_ESC ] ) { destroy_bitmap( koniec ); destroy_bitmap( bufor ); destroy_bitmap( tlo ); } } } while( !key[ KEY_ESC ] ); destroy_bitmap( bufor ); }; void menu( BITMAP * bufor, int maxx, int maxy ) { BITMAP * klawisz = NULL; klawisz = create_bitmap( 200, 200 ); blit( klawisz, screen, 0, 0, 200, 200, 200, 200 ); do { if( key[ KEY_S ] ) Gra( bufor, 800, 600 ); myszka(); blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); show_mouse( bufor ); blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); } while( !key[ KEY_Q ] ); destroy_bitmap( klawisz ); destroy_bitmap( bufor ); }; int main() { allegro_init(); install_keyboard(); set_color_depth( 16 ); install_mouse(); show_mouse( screen ); unscare_mouse(); set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 ); clear_to_color( screen, makecol( 46, 54, 140 ) ); BITMAP * bufor = NULL; bufor = create_bitmap( 800, 600 ); if( bufor ) { menu( bufor, 800, 600 ); } else clear_keybuf(); destroy_bitmap( bufor ); allegro_exit(); return 0; }
END_OF_MAIN();
|