Dragonfly  4.3
A text-based game engine
Particle.h
1 ///
2 /// A particle
3 ///
4 
5 #ifndef __PARTICLE_H__
6 #define __PARTICLE_H__
7 
8 // Engine include.
9 #include "Object.h"
10 
11 namespace df {
12 
13 /// Constants.
14 const int NO_SPREAD=0; // Particles spread.
15 
16 /// Particle types.
18  UNDEFINED_PARTICLE_TYPE = -1,
19  SMOKE,
20  SPARKS,
21  RINGS,
22  FIREWORKS,
23 };
24 
25 /// Particle classes.
27  UNDEFINED_PARTICLE_CLASS = -1,
28  PARTICLE,
29  FIREWORK,
30 };
31 
32 /// Directions.
33 enum Direction {
34  UNDEFINED_DIRECTION = -1,
35  UP,
36  DOWN,
37  LEFT,
38  RIGHT,
39 };
40 
41 class Particle : public Object {
42 
43  private:
44  int m_age; ///< Age to live (in ticks).
45 
46  public:
47  /// Create particle with size (pixels), age (in ticks), opacity
48  /// (0-255) and rgb color.
49  Particle(float size, int age, unsigned char opacity,
50  unsigned char r, unsigned char g, unsigned char b);
51 
52  /// Set age.
53  void setAge(int new_age);
54 
55  /// Get age.
56  int getAge() const;
57 
58  /// Handle step events.
59  /// Return 0 if ignored, else 1.
60  int eventHandler(const Event *p_e);
61 };
62 
63 } // end of namespace df
64 #endif //__PARTICLE_H__
int eventHandler(const Event *p_e)
Handle step events.
Particle(float size, int age, unsigned char opacity, unsigned char r, unsigned char g, unsigned char b)
Create particle with size (pixels), age (in ticks), opacity (0-255) and rgb color.
ParticleClass
Particle classes.
Definition: Particle.h:26
Definition: Particle.h:41
void setAge(int new_age)
Set age.
Direction
Directions.
Definition: Particle.h:33
Definition: Event.h:15
int getAge() const
Get age.
A 2-d bounding box.
Definition: Box.h:10
int m_age
Age to live (in ticks).
Definition: Particle.h:44
const int NO_SPREAD
Constants.
Definition: Particle.h:14
ParticleType
Particle types.
Definition: Particle.h:17
Definition: Object.h:59