#include "pixelGameEngine.h" #include using namespace olc; class Smoke{ float riseSpd; std::vector points; std::vector uvs; std::vector cols; vf2d size; vf2d pos; float fadeSpd=1; //How much alpha to drop down per second. int freq=rand()%2+1; float alpha=128; public: Smoke(vf2d size, vf2d pos, float riseSpd=5.f, float fadeSpd=100) :size(size),riseSpd(riseSpd),fadeSpd(fadeSpd) { int ind=0; points.push_back({pos.x,pos.y}); uvs.push_back({0,0}); cols.push_back(Pixel(128,128,128,128)); for (float i=0;i<2*M_PI;i+=2*M_PI/64) { points.push_back({sinf(i)*size.x+pos.x,cosf(i)*size.y+pos.y}); uvs.push_back({0,0}); cols.push_back(Pixel(128,128,128,128)); } points.push_back(points[1]); uvs.push_back({0,0}); cols.push_back(Pixel(128,128,128,128)); }; void update(float fElapsedTime) { alpha=std::clamp(alpha-fadeSpd*fElapsedTime,0.f,255.f); for (int i=0;iDrawPolygonDecal(nullptr,points,uvs,cols); } bool expired() { for (int i=0;i0) { return false; } } return true; } };