#include "util.h" namespace util{ float random(float range){ return float(rand())/RAND_MAX*range; } void ApplyMatrixEffect(PixelGameEngine*pge,Renderable&r,Renderable&originalImg,std::unique_ptr&matrixImg){ pge->SetDrawTarget(r.Sprite()); pge->Clear(BLANK); for(int y=0;yheight;y++){ for(int x=0;xwidth;x++){ Pixel col=originalImg.Sprite()->GetPixel(x,y); if(col==WHITE){ pge->Draw({x,y},matrixImg->Sprite()->GetPixel(x,y)); } else { pge->Draw({x,y},originalImg.Sprite()->GetPixel(x,y)); } } } pge->SetDrawTarget(nullptr); r.Decal()->Update(); }; }