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

63 lines
2.0 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;
}
};
class FireFountainEffect:public Effect{
int fountainDensity=0;
int lifetime=0;
public:
FireFountainEffect(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 FireParticle({(double)(rand()%3+1),(double)(rand()%3+1)},{0,rand()%10/10.0F+0.1F},lifetime,Pixel(255,rand()%255,0)));
}
for (int i=0;i<60;i++) {
PARTICLES.push_back(new StaticLineParticle(maxLifeTime,Pixel(255,rand()%255,0,rand()%255)));
}
}
bool update()override{
lifetime--;
return lifetime>0;
}
};
#endif