Dragonfly 4.19
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
11namespace df {
12
13/// Constants.
14const 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.
34 UNDEFINED_DIRECTION = -1,
35 UP,
36 DOWN,
37 LEFT,
38 RIGHT,
39};
40
41class 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) override;
61
62 /// Log warning if trying to serialize particles.
63 virtual std::string serialize(std::string attr="") override;
64
65 /// Log warning if trying to deserialize particles.
66 virtual int deserialize(std::string s) override;
67};
68
69} // end of namespace df
70#endif //__PARTICLE_H__
Definition: Event.h:15
Definition: Object.h:59
Definition: Particle.h:41
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.
void setAge(int new_age)
Set age.
virtual int deserialize(std::string s) override
Log warning if trying to deserialize particles.
int getAge() const
Get age.
int m_age
Age to live (in ticks).
Definition: Particle.h:44
int eventHandler(const Event *p_e) override
Handle step events.
virtual std::string serialize(std::string attr="") override
Log warning if trying to serialize particles.
An animation for a sprite.
Definition: Animation.h:15
ParticleClass
Particle classes.
Definition: Particle.h:26
const int NO_SPREAD
Constants.
Definition: Particle.h:14
ParticleType
Particle types.
Definition: Particle.h:17
Direction
Directions.
Definition: Particle.h:33