Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
particleEmitter.h
1 
10 #ifndef PARTICLES_H_DEFINED
11 #define PARTICLES_H_DEFINED
12 
13 #include "core.h"
14 #include <Entities\component.h>
15 #include <Renderer\rectangleShape.h>
16 #include <Renderer\color.h>
17 
18 namespace rune{
19 
20 class RUNE_ENGINE ParticleEmitter : public Component
21 {
22 
23 private:
25  struct particle
26  {
27  rune::Vec2 m_pixelPosition;
28  rune::Color m_pixelColor; //Color of all particles
29  rune::Vec2 m_particleSpeed; //Rate at which particles travel
30  //RectangleShape m_particleSprite[4];
31  int m_timeExisted; //Time the pixel has existed in milliseconds
32  };
33 
34  const int PARTICLELIMIT = 1000;
35  double m_dissolutionRate; //Rate at which particles disappear
36 
37  rune::Color m_pixelBaseColor; //Starting color, can apply modifiers later
38 
39  rune::Vec2 m_canvasSize = rune::Vec2(100,100);
40 
41  rune::Vec2 m_initVel;
42  rune::Vec2 m_startPos; //Location at which the particles start
43  rune::Vec2 m_gravity; //Influence particle velocities
44 
45  std::vector<particle> m_particles;
46 
48  //virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
49 
50 public:
52  ParticleEmitter(rune::Vec2 startPos, rune::Vec2 initVel, rune::Color color, int dissolutionRate = 5, rune::Vec2 gravity = rune::Vec2(0,0));
53 
55  void setDissolutionRate(double rate);
56 
58  void setGravity(rune::Vec2 gravity);
59 
61  void fuel(int particles);
62 
64  void update(double dT);
65 
66  //Set the region that the particle is allowed to move around in.
67  void setCanvasSize(rune::Vec2);
68 
69  //Set the position of the particles emitter.
70  void setPosition(rune::Vec2);
71 
72 };
73 }
74 
75 #endif
rune::Component
A component of a rune::GameObject, this class is used to add functionality to a object in the game wo...
Definition: component.h:23
rune::ParticleEmitter
Class responsible for creating particle emitters and managing the creation of particles.
Definition: particleEmitter.h:21
rune::Vec2
1 x 2 vector to be used for math.
Definition: vec2.h:20
rune::Color
A color object to be applied to drawable objects.
Definition: color.h:19
rune
The main namespace to be used for interfacing with the engine.
Definition: animator.h:21