generated from sigonasr2/CPlusPlusProjectTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
#ifndef EFFECT_H
|
|
#define EFFECT_H
|
|
#include "particle.h"
|
|
#include "pixelGameEngine.h"
|
|
using namespace olc;
|
|
|
|
class Effect{
|
|
public:
|
|
std::vector<Particle*> particles;
|
|
int maxLifeTime=0;
|
|
virtual void create(std::vector<Particle*>&PARTICLES)=0;
|
|
virtual bool update()=0;
|
|
Effect(){}
|
|
void render(PixelGameEngine*game) {
|
|
for (int i=0;i<particles.size();i++) {
|
|
particles[i]->render(game);
|
|
}
|
|
}
|
|
};
|
|
|
|
class FountainEffect:public Effect{
|
|
int fountainDensity=0;
|
|
int lifetime=0;
|
|
public:
|
|
FountainEffect(int fountainDensity,int lifetime)
|
|
:fountainDensity(fountainDensity),lifetime(lifetime){
|
|
this->maxLifeTime=lifetime;
|
|
}
|
|
void create(std::vector<Particle*>&PARTICLES){
|
|
lifetime=maxLifeTime;
|
|
for (int i=0;i<fountainDensity;i++) {
|
|
PARTICLES.push_back(new WaterParticle({WIDTH/2,HEIGHT},{(double)(rand()%3+1),(double)(rand()%3+1)},{0,rand()%10/10.0F+0.1F},lifetime,Pixel(rand()%128,rand()%128,255)));
|
|
}
|
|
}
|
|
bool update()override{
|
|
lifetime--;
|
|
return lifetime>0;
|
|
}
|
|
};
|
|
|
|
FountainEffect*FOUNTAIN_EFFECT;
|
|
#endif |