diff --git a/main.h b/main.h index d454694..878f03d 100644 --- a/main.h +++ b/main.h @@ -37,6 +37,11 @@ struct About { ALLEGRO_BITMAP *fade_bitmap, *image; }; +struct Map { + ALLEGRO_BITMAP *map, *background, *map_bg, *highlight; + int selected, available; +}; + struct Intro { int position; int page; @@ -58,6 +63,7 @@ struct Game { struct Loading loading; struct Intro intro; struct About about; + struct Map map; }; void PreloadGameState(struct Game *game); diff --git a/map.c b/map.c index 8253573..fe12ddc 100644 --- a/map.c +++ b/map.c @@ -1,19 +1,65 @@ #include #include +#include #include "map.h" void Map_Draw(struct Game *game) { - al_clear_to_color(al_map_rgb(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(3.0); - UnloadGameState(game); - game->gamestate = GAMESTATE_LOADING; - game->loadstate = GAMESTATE_MENU; + //al_clear_to_color(al_map_rgb(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(3.0); + //UnloadGameState(game); + //game->gamestate = GAMESTATE_LOADING; + //game->loadstate = GAMESTATE_MENU; + al_draw_bitmap(game->map.map, 0, 0, 0); } -void Map_Load(struct Game *game) {} -int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void Map_Preload(struct Game *game) {} -void Map_Unload(struct Game *game) {} +void Map_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->map.map,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0); + DrawConsole(game); + al_flip_display(); + } +} +int Map_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 Map_Preload(struct Game *game) { + game->map.available = 6; + game->map.selected = game->map.available; +// ALLEGRO_BITMAP *map, *background, *map_bg, *highlight; + game->map.map = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)); + game->map.background = al_load_bitmap( "table.png" ); + game->map.map_bg = al_load_bitmap( "map/background.png" ); + //char* filename = "map/highlight1.png"; + //sprintf(filename, "map/highlight%d.png", game->map.available); + //printf("%s\n", filename); + game->map.highlight = al_load_bitmap( "map/highlight6.png" ); + al_set_target_bitmap(game->map.map); + al_draw_scaled_bitmap(game->map.background,0,0,al_get_bitmap_width(game->map.background),al_get_bitmap_height(game->map.background),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0); + al_draw_scaled_bitmap(game->map.map_bg,0,0,al_get_bitmap_width(game->map.map_bg),al_get_bitmap_height(game->map.map_bg),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0); + al_draw_scaled_bitmap(game->map.highlight,0,0,al_get_bitmap_width(game->map.highlight),al_get_bitmap_height(game->map.highlight),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0); + al_set_target_bitmap(al_get_backbuffer(game->display)); +} +void Map_Unload(struct Game *game) { + ALLEGRO_EVENT ev; + for(int fadeloop=255; fadeloop>=0; fadeloop-=10){ + al_wait_for_event(game->event_queue, &ev); + al_draw_tinted_bitmap(game->map.map, 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->map.map); + al_destroy_bitmap(game->map.background); + al_destroy_bitmap(game->map.map_bg); + al_destroy_bitmap(game->map.highlight); +}