-
Notifications
You must be signed in to change notification settings - Fork 2
Swarm.h and .cpp
Hannupekka Sormunen edited this page Dec 10, 2018
·
6 revisions
//Header guards for SWARM_H_
#ifndef SWARM_H_
#define SWARM_H_
//Include local headers
#include "Screen.h"
#include "Particle.h"
//Create a namespace for this the use of this class
namespace particlefire {
//Create a class Swarm inside namespace ParticleFire. This class devires from Screen-class.
class Swarm : public Screen {
//Private data members of a Swarm-class:
private:
Particle *m_particles;
int m_lastTime;
static int nparticles_;
static double red_speed_;
static double green_speed_;
static double blue_speed_;
//Public data members of a Swarm-class:
public:
//Constructors and destructor of Swarm-class
public:
Swarm();
virtual ~Swarm();
//Private data methods of a Swarm-class:
private:
bool ReadSettings();//Method for getting settings from a file
//Public data methods of a Swarm-class:
public:
void Update(int elapsed);//Method for updating particles
const Particle *const GetParticles() { return m_particles; };//Method for returning the pointer m_pParticles
void SetParticleColorValue(int elapsed);//Method for setting particle's color value
};
}/* end of namespace ParticleFire */
#endif /* SWARM_H_ */ Swarm::Swarm() {
//Constructor that creates array of Particle-objects and saves their location to pointer m_pParticles.
ReadSettings();
m_particles = new Particle[nparticles_];
//Initialize variable to zero
m_lastTime = 0;
}