NWengine 0.9
Loading...
Searching...
No Matches
ParticleSystem.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "GameObject.h"
9#include "Sprite.h"
10#include "Transform.h"
11#include "Globals.h"
12#include "Interpolation.h"
13#include <deque>
14
19#define SHADER_PARTICLES_DEFAULT "Ressources\\Shaders\\ParticleBatched.shader"
20
25#define TEXTURE_PARTICLES_DEFAULT "Ressources\\Images\\DefaultBox10x10.png"
26
46
77
83private:
84 double clock = 0.0;
85public:
86 static std::string GetType() { return "ParticleSystem"; };
87
89 ParticleSystem() {};
92
93 static std::map<GameObject*, ParticleSystem> componentList;
95 bool isActive = true;
96 std::deque<Particle> pool;
97 std::deque<int> disabled;
98 std::deque<int> enabled;
99 int maxParticles = 100;
100 double emissionFrequency = 1.0;
101 uint16 emissionQuantity = 1;
102 int initNum = 5;
104 bool recycle = 1;
111 void Update();
112
117 void UpdateParticle(int index);
118
122 void Emit();
123
127 void Init();
128
132 void InitParticle();
133
140 int Serialize(std::fstream* data, int offset) override;
141
148 int Deserialize(std::fstream* data, int offset) override;
149};
Defines the GameObject class and its related components.
#define SHADER_PARTICLES_DEFAULT
The default shader for particles.
Definition ParticleSystem.h:19
#define TEXTURE_PARTICLES_DEFAULT
The default texture for particles.
Definition ParticleSystem.h:25
Defines the Sprite class, which represents a game sprite.
The BezierInterpolator class represents a Bezier curve interpolator.
Definition Interpolation.h:61
Base class for game components.
Definition GameObject.h:29
Class representing a game object.
Definition GameObject.h:68
Represents a particle.
Definition ParticleSystem.h:51
Transform * transform
Definition ParticleSystem.h:56
float distance
Definition ParticleSystem.h:65
void Disable()
Disables the particle.
Definition ParticleSystem.cpp:121
fVec2 currentScale
Definition ParticleSystem.h:60
GameObject go
Definition ParticleSystem.h:54
bool isActive
Definition ParticleSystem.h:57
fVec2 currentPosition
Definition ParticleSystem.h:59
double clock
Definition ParticleSystem.h:64
Sprite * sprite
Definition ParticleSystem.h:55
float currentSpeed
Definition ParticleSystem.h:61
fVec4 currentColor
Definition ParticleSystem.h:62
fVec2 currentDirection
Definition ParticleSystem.h:63
ParticleProperties prop
Definition ParticleSystem.h:58
void Enable()
Enables the particle.
Definition ParticleSystem.cpp:126
Represents a particle system component that can be attached to a game object.
Definition ParticleSystem.h:82
void Init()
Initializes the particle system.
Definition ParticleSystem.cpp:96
void Update()
Updates the particle system.
Definition ParticleSystem.cpp:15
int maxParticles
Definition ParticleSystem.h:99
std::string shader
Definition ParticleSystem.h:105
uint16 emissionQuantity
Definition ParticleSystem.h:101
int Serialize(std::fstream *data, int offset) override
Serializes the particle system.
Definition ParticleSystem.cpp:145
bool recycle
Definition ParticleSystem.h:104
std::deque< int > enabled
Definition ParticleSystem.h:98
void UpdateParticle(int index)
Updates a particle.
Definition ParticleSystem.cpp:108
static std::map< GameObject *, ParticleSystem > componentList
Definition ParticleSystem.h:93
double emissionFrequency
Definition ParticleSystem.h:100
void Emit()
Emits particles.
Definition ParticleSystem.cpp:53
void InitParticle()
Initializes a particle.
Definition ParticleSystem.cpp:86
std::string texture
Definition ParticleSystem.h:106
GameObject * attachedObj
Definition ParticleSystem.h:88
bool isActive
Definition ParticleSystem.h:95
std::deque< int > disabled
Definition ParticleSystem.h:97
std::deque< Particle > pool
Definition ParticleSystem.h:96
int initNum
Definition ParticleSystem.h:102
ParticleProperties prop
Definition ParticleSystem.h:103
int Deserialize(std::fstream *data, int offset) override
Deserializes the particle system.
Definition ParticleSystem.cpp:179
Represents a game sprite.
Definition Sprite.h:26
The Transform class represents the transformation of a game object.
Definition Transform.h:9
Structure that holds the properties of a particle.
Definition ParticleSystem.h:31
int lifedistance
Definition ParticleSystem.h:34
BezierInterpolator colorY
Definition ParticleSystem.h:41
float lifetime
Definition ParticleSystem.h:33
BezierInterpolator colorZ
Definition ParticleSystem.h:42
BezierInterpolator colorA
Definition ParticleSystem.h:43
BezierInterpolator speed
Definition ParticleSystem.h:44
fVec2 absoluteStartPosition
Definition ParticleSystem.h:32
BezierInterpolator directionX
Definition ParticleSystem.h:36
BezierInterpolator directionY
Definition ParticleSystem.h:37
BezierInterpolator scaleY
Definition ParticleSystem.h:39
BezierInterpolator colorX
Definition ParticleSystem.h:40
fVec2 sPosition
Definition ParticleSystem.h:35
BezierInterpolator scaleX
Definition ParticleSystem.h:38