diff --git a/about.c b/about.c index c04abef..027b4e5 100644 --- a/about.c +++ b/about.c @@ -4,16 +4,49 @@ void About_Draw(struct Game *game) { al_clear_to_color(al_map_rgb(0,0,0)); + al_draw_bitmap(game->about.image, 0, 0, 0); al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2, ALLEGRO_ALIGN_CENTRE, "Not implemented yet!"); - DrawConsole(game); - al_flip_display(); - al_rest(5.0); - UnloadGameState(game); - game->gamestate = GAMESTATE_LOADING; - game->loadstate = GAMESTATE_MENU; } -void About_Load(struct Game *game) {} -int About_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void About_Preload(struct Game *game) {} -void About_Unload(struct Game *game) {} +void About_Load(struct Game *game) { + ALLEGRO_EVENT ev; + for(int fadeloop=0; fadeloop<256; fadeloop+=10){ + al_wait_for_event(game->event_queue, &ev); + al_draw_tinted_bitmap(game->about.fade_bitmap,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0); + DrawConsole(game); + al_flip_display(); + } + al_destroy_bitmap(game->about.fade_bitmap); +} +int About_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { + if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) { + UnloadGameState(game); + game->gamestate = GAMESTATE_LOADING; + game->loadstate = GAMESTATE_MENU; + return 0; + } +} +void About_Preload(struct Game *game) { + game->about.image = al_load_bitmap( "table.png" ); + game->about.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)); + al_set_target_bitmap(game->about.fade_bitmap); + al_draw_bitmap(game->about.image,0,0,0); + al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2, ALLEGRO_ALIGN_CENTRE, "Not implemented yet!"); + al_set_target_bitmap(al_get_backbuffer(game->display)); +} +void About_Unload(struct Game *game) { + ALLEGRO_EVENT ev; + game->about.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)); + al_set_target_bitmap(game->about.fade_bitmap); + al_draw_bitmap(game->about.image,0,0,0); + al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2, ALLEGRO_ALIGN_CENTRE, "Not implemented yet!"); + al_set_target_bitmap(al_get_backbuffer(game->display)); + for(int fadeloop=255; fadeloop>=0; fadeloop-=10){ + al_wait_for_event(game->event_queue, &ev); + al_draw_tinted_bitmap(game->about.fade_bitmap, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0); + DrawConsole(game); + al_flip_display(); + } + al_destroy_bitmap(game->about.image); + al_destroy_bitmap(game->about.fade_bitmap); +} diff --git a/main.h b/main.h index af97ee5..d454694 100644 --- a/main.h +++ b/main.h @@ -33,6 +33,10 @@ struct Loading { ALLEGRO_BITMAP *loading_bitmap, *image; }; +struct About { + ALLEGRO_BITMAP *fade_bitmap, *image; +}; + struct Intro { int position; int page; @@ -53,6 +57,7 @@ struct Game { struct Menu menu; struct Loading loading; struct Intro intro; + struct About about; }; void PreloadGameState(struct Game *game);