[ALLEGRO 5] Lagowanie programu
Ostatnio zmodyfikowano 2014-07-24 15:00
pc_piotrelk Temat założony przez niniejszego użytkownika |
[ALLEGRO 5] Lagowanie programu » 2014-07-23 13:19:23 Programy które robiłem póki nie używałem dużego obrazka były ok. Ostatnio naszła mnie chęć zrobienia snakea. Stworzyłem więc plansze 800x600 i załadowałem do gry. Efekt? Strasznie mało fpsów. Nie wiem co z tym zrobić, a grać się tak nie da. Obrazek ten ma 250kb, jeśli załaduje jakiś co ma np. 50kb to problemu nie ma, ale wtedy nie ma i jakości.. Przy okazji, jeśli mam tą plansze 800x600 a będę chciał zrobić zmiane rozdzielczości, to muszę skombinować planszę w wiekszej rozdzielczości, czy da się to jakoś przeskalować? Oto kod: #include <allegro5/allegro.h> #include <allegro5/allegro_native_dialog.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_native_dialog.h>
void main()
{ al_init(); al_install_keyboard(); al_install_mouse(); al_init_primitives_addon(); al_init_font_addon(); al_init_image_addon(); al_init_native_dialog_addon(); int x = 220, y = 220; ALLEGRO_FONT * font8 = al_create_builtin_font(); ALLEGRO_KEYBOARD_STATE klawiatura; ALLEGRO_MOUSE_STATE mysz; const int maxframe = 1; int curframe = 0; int framecount = 0; int framedelay = 1; ALLEGRO_BITMAP * image[ maxframe ]; ALLEGRO_BITMAP * plansza = al_load_bitmap( "plansza.gif" ); ALLEGRO_TIMER * timer = al_create_timer( 1.0 / 60.0 ); ALLEGRO_EVENT_QUEUE * event_queue = al_create_event_queue(); al_register_event_source( event_queue, al_get_keyboard_event_source() ); al_register_event_source( event_queue, al_get_timer_event_source( timer ) ); al_start_timer( timer ); al_set_new_display_flags( ALLEGRO_WINDOWED ); ALLEGRO_DISPLAY * okno = al_create_display( 800, 600 ); al_set_window_title( okno, "Pierwsza gra xD" ); al_show_mouse_cursor( okno ); double czas = al_get_time(); while( !al_key_down( & klawiatura, ALLEGRO_KEY_ESCAPE ) ) { ALLEGRO_EVENT events; al_wait_for_event( event_queue, & events ); ALLEGRO_MOUSE_STATE state; al_get_mouse_state( & state ); al_get_keyboard_state( & klawiatura ); al_get_mouse_state( & mysz ); if( events.type == ALLEGRO_EVENT_TIMER ) { if( ++framecount >= framedelay ) { if( ++curframe >= maxframe ) { curframe = 0; framecount = 0; } } if( al_get_mouse_state_axis( & state, 0 ) ) { x = state.x; } if( al_get_mouse_state_axis( & state, 1 ) ) { y = state.y; } al_draw_bitmap( plansza, 0, 0, 0 ); al_draw_filled_circle( state.x, state.y, 4, al_map_rgb( 128, 128, 128 ) ); al_draw_filled_circle( state.x - 8, state.y, 4, al_map_rgb( 128, 128, 128 ) ); al_flip_display(); al_clear_to_color( al_map_rgb( 0, 0, 128 ) ); } } }
|
|
pc_piotrelk Temat założony przez niniejszego użytkownika |
» 2014-07-24 15:00:01 Nikt nic wie? Proszę, niech mi ktoś pomoże.. EDIT: Obrazek był tworzony przed utworzeniem okna dlatego tak się działo. https://www.allegro.cc/forums/thread/614271 |
|
« 1 » |