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.
 
 
 
VirusAttack/olcCodeJam2023Entry/util.cpp

23 lines
637 B

#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<Renderable>&matrixImg){
pge->SetDrawTarget(r.Sprite());
pge->Clear(BLANK);
for(int y=0;y<r.Sprite()->height;y++){
for(int x=0;x<r.Sprite()->width;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();
};
}