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, int r, int g, int b, int a)
52 glColor4ub(r, g, b,a);
54 glDisable(GL_TEXTURE_2D);
61 glEnable(GL_TEXTURE_2D);
64 void fadeout(int fade_time)
66 float alpha_inc = 256 / (fade_time / LOOP_DELAY);
71 fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,0, (int)alpha_inc); // left side
74 sound_manager->update();
76 SDL_Delay(int(LOOP_DELAY));
79 fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 255);
82 void shrink_fade(const Vector& point, int fade_time)
84 float left_inc = point.x / ((float)fade_time / LOOP_DELAY);
85 float right_inc = (SCREEN_WIDTH - point.x) / ((float)fade_time / LOOP_DELAY);
86 float up_inc = point.y / ((float)fade_time / LOOP_DELAY);
87 float down_inc = (SCREEN_HEIGHT - point.y) / ((float)fade_time / LOOP_DELAY);
89 float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
91 while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
92 up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y) {
94 right_cor += right_inc;
98 fillrect(0, 0, left_cor, SCREEN_HEIGHT, 0,0,0); // left side
99 fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, 0,0,0); // right side
100 fillrect(0, 0, SCREEN_WIDTH, up_cor, 0,0,0); // up side
101 fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, 0,0,0); // down side
103 SDL_GL_SwapBuffers();
105 sound_manager->update();
106 SDL_Delay(int(LOOP_DELAY));