1 // $Id: screen.cpp 2334 2005-04-04 16:26:14Z grumbel $
3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "gameconfig.hpp"
35 #include "video/drawing_context.hpp"
36 #include "audio/sound_manager.hpp"
37 #include "math/vector.hpp"
39 static const float LOOP_DELAY = 20.0;
41 void fillrect(float x, float y, float w, float h, const Color& col)
52 glColor4f(col.red, col.green, col.blue, col.alpha);
54 glDisable(GL_TEXTURE_2D);
61 glEnable(GL_TEXTURE_2D);
63 glColor4f(0, 0, 0, 1);
66 void fadeout(float fade_time)
68 float alpha_inc = LOOP_DELAY / fade_time;
69 Color c(0, 0, 0, alpha_inc);
74 fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, c);
78 sound_manager->update();
80 SDL_Delay(int(LOOP_DELAY));
84 fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, Color());
87 void shrink_fade(const Vector& point, float fade_time)
89 float left_inc = point.x / (fade_time / LOOP_DELAY);
90 float right_inc = (SCREEN_WIDTH - point.x) / (fade_time / LOOP_DELAY);
91 float up_inc = point.y / (fade_time / LOOP_DELAY);
92 float down_inc = (SCREEN_HEIGHT - point.y) / (fade_time / LOOP_DELAY);
94 float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
97 while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
98 up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y) {
100 right_cor += right_inc;
102 down_cor += down_inc;
104 fillrect(0, 0, left_cor, SCREEN_HEIGHT, c); // left side
105 fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, c); // right side
106 fillrect(0, 0, SCREEN_WIDTH, up_cor, c); // up side
107 fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, c); // down side
109 SDL_GL_SwapBuffers();
111 sound_manager->update();
112 SDL_Delay(int(LOOP_DELAY));