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.
SeasonI/effect.h

33 lines
1.0 KiB

class Effect{
public:
std::vector<Particle*> particles;
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 maxLifeTime=0;
int lifetime=0;
public:
FountainEffect(int fountainDensity,int lifetime)
:fountainDensity(fountainDensity),lifetime(lifetime),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},{rand()%3+1,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;