tibia-client/src/framework/graphics/particle.h

66 lines
2.4 KiB
C
Raw Normal View History

2011-12-15 21:55:05 +01:00
/*
2017-01-13 11:47:07 +01:00
* Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
2011-12-15 21:55:05 +01:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef PARTICLE_H
#define PARTICLE_H
#include "declarations.h"
2013-02-22 07:31:13 +01:00
#include "painter.h"
2011-12-15 21:55:05 +01:00
class Particle : public stdext::shared_object
{
2011-12-15 21:55:05 +01:00
public:
2011-12-19 04:24:35 +01:00
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);
2011-12-15 21:55:05 +01:00
void render();
2012-03-20 16:17:10 +01:00
void update(float elapsedTime);
2011-12-15 21:55:05 +01:00
bool hasFinished() { return m_finished; }
2012-01-30 01:00:12 +01:00
PointF getPosition() { return m_position; }
2011-12-16 02:59:29 +01:00
PointF getVelocity() { return m_velocity; }
2012-01-30 01:00:12 +01:00
void setPosition(const PointF& position) { m_position = position; }
2011-12-16 02:59:29 +01:00
void setVelocity(const PointF& velocity) { m_velocity = velocity; }
2011-12-15 21:55:05 +01:00
private:
2011-12-18 03:21:12 +01:00
void updateColor();
2012-03-20 16:17:10 +01:00
void updatePosition(float elapsedTime);
2011-12-26 07:14:57 +01:00
void updateSize();
2011-12-18 03:21:12 +01:00
2011-12-15 21:55:05 +01:00
Color m_color;
2011-12-18 03:21:12 +01:00
std::vector<Color> m_colors;
std::vector<float> m_colorsStops;
2011-12-15 21:55:05 +01:00
TexturePtr m_texture;
2012-01-30 01:00:12 +01:00
PointF m_position;
2011-12-15 21:55:05 +01:00
PointF m_velocity;
PointF m_acceleration;
2011-12-18 03:54:35 +01:00
Size m_size, m_startSize, m_finalSize;
2011-12-15 21:55:05 +01:00
Rect m_rect;
2011-12-19 04:24:35 +01:00
Painter::CompositionMode m_compositionMode;
float m_duration, m_ignorePhysicsAfter;
2012-03-20 16:17:10 +01:00
float m_elapsedTime;
2011-12-15 21:55:05 +01:00
bool m_finished;
};
#endif