Arcade Shooter
Particle.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
16  class ParticleTemplate;
17 
19  class Particle
20  {
21 
22  friend class ParticleTemplate;
23  friend class ParticleManager;
24  friend class Emitter;
25 
26  public:
27 
28  Particle();
29  virtual ~Particle() { s_count--; }
30 
33  virtual float GetInterpolationValue();
34 
35 
38  virtual void SetLifespan(const float seconds) { m_lifespan = seconds; }
39 
42  virtual void SetTemplate(ParticleTemplate *pTemplate) { m_pTemplate = pTemplate; }
43 
46  virtual void SetPosition(const Vector2 position) { m_position = position; }
47 
50  virtual Vector2 &GetPosition() { return m_position; }
51 
54  virtual void SetAlpha(const float alpha) { m_alpha = alpha; }
55 
58  virtual float GetAlpha() const { return m_alpha; }
59 
62  virtual void SetScale(const Vector2 scale) { m_scale = scale; }
63 
66  virtual Vector2 GetScale() const { return m_scale; }
67 
70  virtual void SetRotation(const float rotation) { m_rotation = rotation; }
71 
74  virtual float GetRotation() const { return m_rotation; }
75 
78  virtual uint32_t GetIndex() const { return m_index; }
79 
80 
81  private:
82 
83  static uint32_t s_count;
84 
85  uint32_t m_index;
86 
87  ParticleTemplate *m_pTemplate;
88 
89  float m_lifespan;
90  float m_lifeSeconds;
91 
92  Vector2 m_position;
93  Color m_color;
94 
95  float m_alpha;
96  float m_rotation;
97  Vector2 m_scale;
98 
99  virtual void Activate() { m_lifeSeconds = m_lifespan; }
100 
101  virtual bool IsActive() const { return m_lifeSeconds > 0; }
102 
103  virtual void Update(const GameTime *pGameTime);
104 
105  virtual void Draw(SpriteBatch *pSpriteBatch);
106 
107  };
108 }
The source of output for a particle effect.
Definition: Emitter.h:18
virtual float GetAlpha() const
Gets the alpha value (opacity) of the particle.
Definition: Particle.h:58
virtual Vector2 GetScale() const
Gets the scale of the particle.
Definition: Particle.h:66
virtual void SetScale(const Vector2 scale)
Sets the particle's scale.
Definition: Particle.h:62
virtual void SetLifespan(const float seconds)
Sets the lifespan of the particle in seconds.
Definition: Particle.h:38
virtual float GetRotation() const
Gets the rotation of the particle.
Definition: Particle.h:74
Contains timing values for game updates and rendering.
Definition: GameTime.h:17
Manages the active particles in a particle system.
Definition: ParticleManager.h:18
Represents a four-component color using red, green, blue, and alpha data.
Definition: Color.h:17
Base class for particle templates which are used to control the updating of a corresponding particle ...
Definition: ParticleTemplate.h:17
Defines a vector with 2 components (x and y). This is additional information...
Definition: Vector2.h:18
virtual uint32_t GetIndex() const
Gets the index of the particle.
Definition: Particle.h:78
virtual void SetRotation(const float rotation)
Sets the particle's rotation.
Definition: Particle.h:70
virtual Vector2 & GetPosition()
Gets the position of the particle.
Definition: Particle.h:50
Enables a group of sprites to be drawn using the same settings.
Definition: SpriteBatch.h:44
A single component of a particle system.
Definition: Particle.h:19
virtual void SetTemplate(ParticleTemplate *pTemplate)
Sets template responsible for updating the particle.
Definition: Particle.h:42
virtual float GetInterpolationValue()
A value representing the percentage of the particle's lifespan.
Definition: Particle.cpp:52
virtual void SetAlpha(const float alpha)
Sets the particle's alpha value (opacity).
Definition: Particle.h:54
virtual void SetPosition(const Vector2 position)
Sets the particle's position.
Definition: Particle.h:46
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14