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 | #ifndef HEADER_SUPERTUX_OBJECT_SNOW_PARTICLE_SYSTEM_HPP |
18 | #define HEADER_SUPERTUX_OBJECT_SNOW_PARTICLE_SYSTEM_HPP |
19 | |
20 | #include "object/particlesystem.hpp" |
21 | #include "supertux/timer.hpp" |
22 | |
23 | class ReaderMapping; |
24 | |
25 | class SnowParticleSystem final : public ParticleSystem |
26 | { |
27 | public: |
28 | SnowParticleSystem(); |
29 | SnowParticleSystem(const ReaderMapping& reader); |
30 | virtual ~SnowParticleSystem(); |
31 | |
32 | virtual void update(float dt_sec) override; |
33 | |
34 | virtual std::string get_class() const override { return "particles-snow" ; } |
35 | virtual std::string get_display_name() const override { return _("Snow Particles" ); } |
36 | |
37 | virtual const std::string get_icon_path() const override { |
38 | return "images/engine/editor/snow.png" ; |
39 | } |
40 | |
41 | void init(); |
42 | |
43 | private: |
44 | class SnowParticle : public Particle |
45 | { |
46 | public: |
47 | float speed; |
48 | float wobble; |
49 | float anchorx; |
50 | float drift_speed; |
51 | |
52 | // Turning speed |
53 | float spin_speed; |
54 | |
55 | // for inertia |
56 | unsigned int flake_size; |
57 | |
58 | SnowParticle() : |
59 | speed(), |
60 | wobble(), |
61 | anchorx(), |
62 | drift_speed(), |
63 | spin_speed(), |
64 | flake_size() |
65 | {} |
66 | }; |
67 | |
68 | // Wind is simulated in discrete "gusts" |
69 | |
70 | // Gust state |
71 | enum State { |
72 | ATTACKING, |
73 | DECAYING, |
74 | SUSTAINING, |
75 | RELEASING, |
76 | RESTING, |
77 | MAX_STATE |
78 | }; |
79 | |
80 | private: |
81 | State state; |
82 | |
83 | // Gust state delay timer |
84 | Timer timer; |
85 | |
86 | // Peak magnitude of gust is gust_onset * randf(5) |
87 | float gust_onset; |
88 | |
89 | // Current blowing velocity of gust |
90 | float gust_current_velocity; |
91 | |
92 | SurfacePtr snowimages[3]; |
93 | |
94 | private: |
95 | SnowParticleSystem(const SnowParticleSystem&) = delete; |
96 | SnowParticleSystem& operator=(const SnowParticleSystem&) = delete; |
97 | }; |
98 | |
99 | #endif |
100 | |
101 | /* EOF */ |
102 | |