From: Ricardo Cruz Date: Mon, 31 May 2004 14:08:11 +0000 (+0000) Subject: Do a black fade-in when selecting slot. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f0dc1755daeb73522f087185da51d2e9e4058783;p=supertux.git Do a black fade-in when selecting slot. To make it really looking good, we would had to have access to the screen. Dunno how we can do this with OpenGL. SVN-Revision: 1374 --- diff --git a/src/screen/screen.cpp b/src/screen/screen.cpp index a9cf2bced..8a442b235 100644 --- a/src/screen/screen.cpp +++ b/src/screen/screen.cpp @@ -288,8 +288,24 @@ if(h < 0) } -void fadeout() +#define LOOP_DELAY 20.0 + +void fadeout(int fade_time) { + float alpha_inc = 256 / (fade_time / LOOP_DELAY); + float alpha = 256; + + while(alpha > 0) + { + alpha -= alpha_inc; + fillrect(0, 0, screen->w, screen->h, 0,0,0, (int)alpha_inc); // left side + + DrawingContext context; // ugly... + context.do_drawing(); + + SDL_Delay(int(LOOP_DELAY)); + } + fillrect(0, 0, screen->w, screen->h, 0, 0, 0, 255); DrawingContext context; @@ -298,13 +314,12 @@ void fadeout() context.do_drawing(); } -#define LOOP_DELAY 20.0 -void shrink_fade(const Vector& point, float fade_time) +void shrink_fade(const Vector& point, int fade_time) { - float left_inc = point.x / (fade_time / LOOP_DELAY); - float right_inc = (screen->w - point.x) / (fade_time / LOOP_DELAY); - float up_inc = point.y / (fade_time / LOOP_DELAY); - float down_inc = (screen->h - point.y) / (fade_time / LOOP_DELAY); + float left_inc = point.x / ((float)fade_time / LOOP_DELAY); + float right_inc = (screen->w - point.x) / ((float)fade_time / LOOP_DELAY); + float up_inc = point.y / ((float)fade_time / LOOP_DELAY); + float down_inc = (screen->h - point.y) / ((float)fade_time / LOOP_DELAY); float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0; diff --git a/src/screen/screen.h b/src/screen/screen.h index 64c42c2aa..4c7f3df77 100644 --- a/src/screen/screen.h +++ b/src/screen/screen.h @@ -36,10 +36,8 @@ class Vector; void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a); void fillrect(float x, float y, float w, float h, int r, int g, int b, int a = 255); -void shrink_fade(const Vector& point, float fade_time); -//void black_fade(Surface* surface, int seconds, bool fade_out); -void fade(const std::string& surface, int seconds, bool fade_out); -void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h); -void fadeout(); + +void fadeout(int fade_time); +void shrink_fade(const Vector& point, int fade_time); #endif /*SUPERTUX_SCREEN_H*/ diff --git a/src/setup.cpp b/src/setup.cpp index 2733624c1..34891f281 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -508,7 +508,7 @@ bool process_load_game_menu() } // shrink_fade(Point((screen->w/2),(screen->h/2)), 1000); - fadeout(); + fadeout(200); WorldMapNS::WorldMap worldmap; // Load the game or at least set the savegame_file variable