Otclient  14/8/2020
particle.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef PARTICLE_H
24 #define PARTICLE_H
25 
26 #include "declarations.h"
27 #include "painter.h"
28 
30 {
31 public:
32  Particle(const Point& pos, const Size& startSize, const Size& finalSize, const PointF& velocity, const PointF& acceleration, float duration, float ignorePhysicsAfter, const std::vector<Color>& colors, const std::vector<float>& colorsStops, Painter::CompositionMode compositionMode = Painter::CompositionMode_Normal, TexturePtr texture = nullptr);
33 
34  void render();
35  void update(float elapsedTime);
36 
37  bool hasFinished() { return m_finished; }
38 
39  PointF getPosition() { return m_position; }
40  PointF getVelocity() { return m_velocity; }
41 
42  void setPosition(const PointF& position) { m_position = position; }
43  void setVelocity(const PointF& velocity) { m_velocity = velocity; }
44 
45 private:
46  void updateColor();
47  void updatePosition(float elapsedTime);
48  void updateSize();
49 
50  Color m_color;
51  std::vector<Color> m_colors;
52  std::vector<float> m_colorsStops;
53  TexturePtr m_texture;
54  PointF m_position;
55  PointF m_velocity;
56  PointF m_acceleration;
57  Size m_size, m_startSize, m_finalSize;
58  Rect m_rect;
59  Painter::CompositionMode m_compositionMode;
60  float m_duration, m_ignorePhysicsAfter;
61  float m_elapsedTime;
62  bool m_finished;
63 };
64 
65 #endif
Particle::setPosition
void setPosition(const PointF &position)
Definition: particle.h:42
Color
Definition: color.h:32
Painter::CompositionMode_Normal
@ CompositionMode_Normal
Definition: painter.h:39
Particle
Definition: particle.h:29
TRect< int >
Particle::Particle
Particle(const Point &pos, const Size &startSize, const Size &finalSize, const PointF &velocity, const PointF &acceleration, float duration, float ignorePhysicsAfter, const std::vector< Color > &colors, const std::vector< float > &colorsStops, Painter::CompositionMode compositionMode=Painter::CompositionMode_Normal, TexturePtr texture=nullptr)
Definition: particle.cpp:27
Particle::getVelocity
PointF getVelocity()
Definition: particle.h:40
Painter::CompositionMode
CompositionMode
Definition: painter.h:38
painter.h
Particle::update
void update(float elapsedTime)
Definition: particle.cpp:58
Particle::getPosition
PointF getPosition()
Definition: particle.h:39
declarations.h
stdext::shared_object_ptr< Texture >
Particle::hasFinished
bool hasFinished()
Definition: particle.h:37
TPoint< int >
Particle::render
void render()
Definition: particle.cpp:46
TSize< int >
Particle::setVelocity
void setVelocity(const PointF &velocity)
Definition: particle.h:43
stdext::shared_object
Definition: shared_object.h:41