Made code -Wshadow clean, missed a bunch of issues in the last commit
[supertux.git] / src / supertux / shrinkfade.cpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #include "supertux/globals.hpp"
18 #include "supertux/shrinkfade.hpp"
19 #include "video/drawing_context.hpp"
20
21 ShrinkFade::ShrinkFade(const Vector& dest_, float fade_time_) :
22   dest(dest_),
23   fade_time(fade_time_),
24   accum_time(0),
25   speedleft(),
26   speedright(),
27   speedtop(),
28   speedbottom()
29 {
30   speedleft = dest.x / fade_time;
31   speedright = (SCREEN_WIDTH - dest.x) / fade_time;
32   speedtop = dest.y / fade_time;
33   speedbottom = (SCREEN_HEIGHT - dest.y) / fade_time;
34 }
35
36 ShrinkFade::~ShrinkFade()
37 {
38 }
39
40 void
41 ShrinkFade::update(float elapsed_time)
42 {
43   accum_time += elapsed_time;
44   if(accum_time > fade_time)
45     accum_time = fade_time;
46 }
47
48 void
49 ShrinkFade::draw(DrawingContext& context)
50 {
51   float progress = accum_time / fade_time;
52   context.draw_inverse_ellipse(dest,
53                                Vector(2*SCREEN_WIDTH  * (1.0f - progress),
54                                       2*SCREEN_HEIGHT * (1.0f - progress)),
55                                Color(0, 0, 0), LAYER_GUI+1);
56 }
57
58 bool
59 ShrinkFade::done()
60 {
61   return accum_time >= fade_time;
62 }
63
64 /* EOF */