supertux
fade_helper.hpp
1 // SuperTux
2 // Copyright (C) 2021 A. Semphris <semphris@protonmail.com>
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 #ifndef HEADER_SUPERTUX_UTIL_FADE_HELPER_HPP
18 #define HEADER_SUPERTUX_UTIL_FADE_HELPER_HPP
19 
20 #include "math/easing.hpp"
21 
23 {
24 public:
26  FadeHelper(float time, float target_value,
27  float start_value = 0.f, easing ease = LinearInterpolation);
28 
30  FadeHelper(float* value, float time,
31  float target_value, easing ease = LinearInterpolation);
32 
33 
40  float update(float dt_sec);
41 
43  bool completed() const;
44 
45  float get_value() const;
46 
47 private:
48  float* m_value;
49  float m_progress;
50  float m_start, m_target,
51  m_time, m_total_time;
52  easing m_ease;
53 
54 private:
55  FadeHelper(const FadeHelper&) = delete;
56  FadeHelper& operator=(const FadeHelper&) = delete;
57 };
58 
59 #endif
60 
61 /* EOF */
float update(float dt_sec)
Increases the internal timer of the FadeHelper.
Definition: fade_helper.cpp:44
Definition: fade_helper.hpp:22
bool completed() const
Definition: fade_helper.cpp:71
FadeHelper(float time, float target_value, float start_value=0.f, easing ease=LinearInterpolation)
Initialize FadeHelper without binding to a value.
Definition: fade_helper.cpp:19