-
Notifications
You must be signed in to change notification settings - Fork 2
Particle.h and .cpp
Hannupekka Sormunen edited this page Dec 10, 2018
·
5 revisions
//Header guards for PARTICLE_H_
#ifndef PARTICLE_H_
#define PARTICLE_H_
//Define guards for _USE_MATH_DEFINES, so that M_PI can be used.
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
//Include C++ system libraries
#include <cmath>
#include <cstdlib>
//Create a namespace for this the use of this class
namespace particlefire {
//Create a class Particle inside namespace ParticleFire.
class Particle {
//Private data members of a Particle-class:
private:
double m_speed;
double m_direction;
double m_xpos;
double m_ypos;
//Public data members of a Particle-class:
public:
//Constructors and destructor of a Particle-class:
public:
Particle();
virtual ~Particle();
//Private data methods of a Particle-class:
private:
void Init();//Method for initializing a single particle's position, traveling speed and direction
//Public data methods of a Particle-class:
public:
void UpdatePosition(int interval);//Method for updating the particle position on the screen
double GetXpos() { return m_xpos; };//Method for acquiring the position of a particle on a x-axis
double GetYpos() { return m_ypos; };//Method for acquiring the position of a particle on a y-axis
};
} /* end of namespace ParticleFire */
#endif /*_USE_MATH_DEFINES*/
#endif /* PARTICLE_H_ */ Particle::Particle() {
//Upon default initilization of an object, private data method Init is called
Init();
}