add logo to main menu, with glass effect

This commit is contained in:
Sebastian Krzyszkowiak 2012-07-03 16:27:57 +02:00
parent 64d0e30135
commit 77ef62b413
3 changed files with 48 additions and 3 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.5.81, 2012-06-19T14:46:09. -->
<!-- Written by Qt Creator 2.5.81, 2012-07-03T14:58:39. -->
<qtcreator>
<data>
<variable>GenericProjectManager.GenericProject.Toolchain</variable>
@ -60,7 +60,7 @@
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericTarget</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="GenericProjectManager.GenericBuildConfiguration.BuildDirectory">/home/dos/git/SuperDerpy</value>
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{2a0f2a2f-6b3a-4e88-a8f0-c4e642a21298}</value>

View file

@ -173,6 +173,8 @@ struct Menu {
ALLEGRO_BITMAP *rain; /*!< Unscaled bitmap with rain drop. */
ALLEGRO_BITMAP *rain_bitmap; /*!< Scaled and "rendered" bitmap with rain drops. */
ALLEGRO_BITMAP *mountain; /*!< Flashing mountain in background bitmap. */
ALLEGRO_BITMAP *logo; /*!< Logo displayed in the background. */
ALLEGRO_BITMAP *glass; /*!< Texture used for glass effect in the logo. */
float cloud_position; /*!< Position of bigger cloud. */
float cloud2_position; /*!< Position of small cloud. */
int mountain_position; /*!< Position of flashing mountain. */

View file

@ -131,6 +131,43 @@ void Menu_Draw(struct Game *game) {
al_draw_bitmap(game->menu.pie_bitmap, al_get_display_width(game->display)/2, al_get_display_height(game->display)*(game->menu.cloud_position)/10,0);
/* GLASS EFFECT */
ALLEGRO_BITMAP *bg = al_create_bitmap(al_get_bitmap_width(game->menu.logo), al_get_bitmap_height(game->menu.logo));
al_set_target_bitmap(bg);
al_draw_bitmap_region(al_get_backbuffer(game->display), (al_get_display_width(game->display)/2)-(al_get_bitmap_width(game->menu.logo)/2), (al_get_display_height(game->display)*0.1), al_get_bitmap_width(game->menu.logo), al_get_bitmap_height(game->menu.logo), 0, 0, 0);
ALLEGRO_BITMAP *bg2 = al_create_bitmap(al_get_bitmap_width(game->menu.logo), al_get_bitmap_height(game->menu.logo));
al_set_target_bitmap(bg2);
al_clear_to_color(al_map_rgba(0,0,0,0));
float alpha = (1.0/5.0);
ALLEGRO_COLOR color = al_map_rgba_f(alpha, alpha, alpha, alpha);
int bx = 0, by = 0;
for (by = -2; by <= 2; by++) {
for (bx = -2; bx <= 2; bx++) {
if (sqrt(bx*bx+by*by) <= 2)
al_draw_tinted_bitmap(bg, color, bx*2, by*2, 0);
}
}
al_destroy_bitmap(bg);
al_draw_bitmap(game->menu.glass, 0, 0, 0);
al_set_blender(ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_ALPHA);
al_draw_bitmap(game->menu.logo, 0, 0, 0);
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
al_set_target_bitmap(al_get_backbuffer(game->display));
al_draw_bitmap(bg2, (al_get_display_width(game->display)/2)-(al_get_bitmap_width(game->menu.logo)/2), (al_get_display_height(game->display)*0.1), 0);
al_destroy_bitmap(bg2);
alpha = (1.0/40.0);
color = al_map_rgba_f(alpha, alpha, alpha, alpha);
for (by = -2; by <= 2; by++) {
for (bx = -2; bx <= 2; bx++) {
if (sqrt(bx*bx+by*by) <= 2)
al_draw_tinted_bitmap(game->menu.logo, color, (al_get_display_width(game->display)/2)-(al_get_bitmap_width(game->menu.logo)/2)+bx, (al_get_display_height(game->display)*0.1)+by, 0);
}
}
al_draw_tinted_bitmap(game->menu.logo, al_map_rgba_f(0.1, 0.1, 0.1, 0.1), (al_get_display_width(game->display)/2)-(al_get_bitmap_width(game->menu.logo)/2), (al_get_display_height(game->display)*0.1), 0);
/* END OF GLASS EFFECT */
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.1, ALLEGRO_ALIGN_CENTRE, "Super Derpy");
al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.275, ALLEGRO_ALIGN_CENTRE, "Muffin Attack");
@ -143,7 +180,7 @@ void Menu_Draw(struct Game *game) {
}
void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
PROGRESS_INIT(13);
PROGRESS_INIT(15);
game->menu.options.fullscreen = game->fullscreen;
game->menu.options.fps = game->fps;
@ -158,6 +195,10 @@ void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
PROGRESS;
game->menu.cloud2 = LoadScaledBitmap( "menu/cloud2.png", al_get_display_width(game->display)*0.2, al_get_display_height(game->display)*0.1 );
PROGRESS;
game->menu.logo = LoadScaledBitmap( "menu/logo.png", al_get_display_width(game->display)*0.3, al_get_display_height(game->display)*0.35 );
PROGRESS;
game->menu.glass = LoadScaledBitmap( "menu/glass.png", al_get_display_width(game->display)*0.3, al_get_display_height(game->display)*0.35 );
PROGRESS;
game->menu.pinkcloud = LoadScaledBitmap( "menu/pinkcloud.png", al_get_display_width(game->display)*0.33125, al_get_display_height(game->display)*0.8122);
PROGRESS;
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
@ -265,6 +306,8 @@ void Menu_Unload(struct Game *game) {
al_destroy_bitmap(game->menu.rain_bitmap);
al_destroy_bitmap(game->menu.mountain);
al_destroy_bitmap(game->menu.pie_bitmap);
al_destroy_bitmap(game->menu.logo);
al_destroy_bitmap(game->menu.glass);
al_destroy_font(game->menu.font_title);
al_destroy_font(game->menu.font_subtitle);
al_destroy_font(game->menu.font);