aaadam Temat założony przez niniejszego użytkownika |
allegro fullscreen gra zaczyna zamulać po przełączeniu z okienka na fullscreen » 2014-04-15 21:26:03 mam 2 problemy: 1: gdy zmienię z fullscreena na okienko lub na odwrót to zaczyna mi się mulić gierka nie wiem dlaczego 2: gdy zmienię z fullscreena na okienko lub na odwrót (chcę zaznaczyć że robię to przyciskiem strzałka_prawo wybieranie standardowo enter oraz góra dół), za pierwszym razem jak 'najadę na przycisk fullcreeen to muszę kliknąć w prawo za drugim razem zmiana następuje automatycznie bez wciskania przycisku w prawo nie rozumiem dlaczego tak się dzieję zamieszczam kod pliku app.cpp mam nadzieję że ktoś pomoże. #include <iostream> #include "app.h" #include "gamedata.h" using namespace std; app::app( void ) : done( 1 ) { } app::~app( void ) { } void app::run() { while( this->done ) { keyboardControl(); update(); draw(); } } void app::keyboardControl() { al_wait_for_event( AllegroInit.event_queue, & AllegroInit.events ); al_get_keyboard_state( & AllegroInit.keyState ); if( AllegroInit.events.type == ALLEGRO_EVENT_DISPLAY_CLOSE ) { this->done = false; } if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_Z ) ) { this->done = false; } if( AllegroInit.events.timer.source == AllegroInit.timer ) { if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_Z ) ) { GameData.Menu = GameData.MainMenu; } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_X ) ) { GameData.Menu = GameData.Options; } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_UP ) ) { if( GameData.Menu == GameData.MainMenu ) { if( GameData.MenuChangeClockStatus <= clock() ) { GameData.MenuChoseStatus -= 1; GameData.MenuChangeClockStatus = clock() + 0.3 * CLOCKS_PER_SEC; } } else if( GameData.Menu == GameData.Options ) { if( GameData.MenuChangeClockStatus <= clock() ) { GameData.MenuChoseStatus -= 1; GameData.MenuChangeClockStatus = clock() + 0.3 * CLOCKS_PER_SEC; } } } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_DOWN ) ) { if( GameData.Menu == GameData.MainMenu ) { if( GameData.MenuChangeClockStatus <= clock() ) { GameData.MenuChoseStatus += 1; GameData.MenuChangeClockStatus = clock() + 0.3 * CLOCKS_PER_SEC; } } else if( GameData.Menu == GameData.Options ) { if( GameData.MenuChangeClockStatus <= clock() ) { GameData.MenuChoseStatus += 1; GameData.MenuChangeClockStatus = clock() + 0.3 * CLOCKS_PER_SEC; } } } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_ENTER ) ) { if( GameData.Menu == GameData.MainMenu && GameData.MenuChangeClockStatus <= clock() ) { if( GameData.MenuChoseStatus == GameData.MenuChoseExit ) this->done = false; else if( GameData.MenuChoseStatus == GameData.MenuChoseOptions ) { GameData.Menu = GameData.Options; GameData.MenuChoseStatus = GameData.MenuBack; GameData.MenuChangeClockStatus = clock() + 0.1 * CLOCKS_PER_SEC; } } else if( GameData.Menu == GameData.Options && GameData.MenuChangeClockStatus <= clock() ) { if( GameData.MenuChoseStatus == GameData.MenuBack ) { GameData.Menu = GameData.MainMenu; GameData.MenuChoseStatus = GameData.MenuChoseOptions; GameData.MenuChangeClockStatus = clock() + 0.1 * CLOCKS_PER_SEC; } } } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_M ) ) { GameData.Menu = GameData.MainMenu; } else if( al_key_down( & AllegroInit.keyState, ALLEGRO_KEY_RIGHT ) ) { if( GameData.Menu == GameData.Options && GameData.MenuChangeClockStatus <= clock() ) { if( GameData.MenuChoseStatus == GameData.MenuFullscreen ) { if( GameData.b_FullscreenMode ) { GameData.b_FullscreenMode = true; GameData.MenuChoseStatus = GameData.MenuVolume; GameData.MenuChangeClockStatus = clock() + 0.1 * CLOCKS_PER_SEC; al_destroy_display( AllegroInit.display ); al_set_new_display_flags( ALLEGRO_FULLSCREEN ); AllegroInit.display = al_create_display( AllegroInit.ScreenWidth, AllegroInit.ScreenHeight ); } else if( !GameData.MenuFullscreen ) { GameData.b_FullscreenMode = false; GameData.MenuChoseStatus = GameData.MenuVolume; GameData.MenuChangeClockStatus = clock() + 0.1 * CLOCKS_PER_SEC; al_destroy_display( AllegroInit.display ); al_set_new_display_flags( ALLEGRO_WINDOWED ); AllegroInit.display = al_create_display( AllegroInit.ScreenWidth, AllegroInit.ScreenHeight ); } } } } } } void app::update() { if( GameData.Menu == GameData.MainMenu ) { GameData.MenuColorChange += 1; if( GameData.MenuColorChange > 255 ) GameData.MenuColorChange = 0; if( GameData.MenuChoseStatus > 2 ) GameData.MenuChoseStatus = 2; if( GameData.MenuChoseStatus < 0 ) GameData.MenuChoseStatus = 0; } else if( GameData.Menu == GameData.Options ) { GameData.MenuColorChange += 1; if( GameData.MenuColorChange > 255 ) GameData.MenuColorChange = 0; if( GameData.MenuChoseStatus > 2 ) GameData.MenuChoseStatus = 2; if( GameData.MenuChoseStatus < 0 ) GameData.MenuChoseStatus = 0; } }
void app::draw() { if( GameData.Menu == GameData.MainMenu ) { al_draw_text( GameData.font, al_map_rgb( GameData.MenuColorChange, GameData.MenuColorChange, 255 ), 10, 0, NULL, "DEAD SPACE" ); if( GameData.MenuChoseStatus == GameData.MenuChoseStart ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 100, NULL, "START" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 100, NULL, "START" ); if( GameData.MenuChoseStatus == GameData.MenuChoseOptions ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 150, NULL, "OPTIONS" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 150, NULL, "OPTIONS" ); if( GameData.MenuChoseStatus == GameData.MenuChoseExit ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 200, NULL, "EXIT" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 200, NULL, "EXIT" ); cout << GameData.MenuChoseStatus << endl; al_flip_display(); al_clear_to_color( al_map_rgb( 0, 0, 0 ) ); } if( GameData.Menu == GameData.Options ) { al_draw_text( GameData.font, al_map_rgb( GameData.MenuColorChange, GameData.MenuColorChange, 255 ), 10, 0, NULL, "DEAD SPACE" ); al_draw_bitmap_region( GameData.GamePalette, 425, 10, 350, 100, 210, 70, NULL ); if( GameData.MenuChoseStatus == GameData.MenuVolume ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 100, NULL, "VOLUME" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 100, NULL, "VOLUME" ); if( GameData.MenuChoseStatus == GameData.MenuFullscreen ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 150, NULL, "FULLSCREEN" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 150, NULL, "FULLSCREEN" ); if( GameData.b_FullscreenMode ) al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 250, 150, NULL, "OFF" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 250, 150, NULL, "ON" ); if( GameData.MenuChoseStatus == GameData.MenuBack ) al_draw_text( GameData.font, al_map_rgb( 255, 255, 255 ), 10, 200, NULL, "BACK" ); else al_draw_text( GameData.font, al_map_rgb( 0, 255, 255 ), 10, 200, NULL, "BACK" ); cout << GameData.MenuChoseStatus << endl; al_flip_display(); al_clear_to_color( al_map_rgb( 0, 0, 0 ) ); } }
|