[Super-tux-commit] supertux/src/screen screen.cpp,1.1,1.2 screen.h,1.1,1.2
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-05-31 14:08:24
|
Update of /cvsroot/super-tux/supertux/src/screen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9074/src/screen Modified Files: screen.cpp screen.h Log Message: 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. Index: screen.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/screen/screen.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- screen.h 30 May 2004 01:08:50 -0000 1.1 +++ screen.h 31 May 2004 14:08:10 -0000 1.2 @@ -36,10 +36,8 @@ 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*/ Index: screen.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/screen/screen.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- screen.cpp 30 May 2004 01:08:50 -0000 1.1 +++ screen.cpp 31 May 2004 14:08:10 -0000 1.2 @@ -288,8 +288,24 @@ } -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 @@ 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; |