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/CollectionPoint.cpp

26 lines
984 B

#include "CollectionPoint.h"
#include "util.h"
CollectionPoint::CollectionPoint(PixelGameEngine*pge,vf2d pos,float rot,Renderable&collectionPointImg,MemoryType type)
:pos(pos),rot(rot),type(type),originalCollectionPointImg(collectionPointImg.Sprite()),randomOffset({util::random(128),util::random(128)}){
img.Create(collectionPointImg.Sprite()->width,collectionPointImg.Sprite()->height);
pge->SetDrawTarget(img.Sprite());
pge->Clear(BLANK);
pge->DrawSprite({0,0},collectionPointImg.Sprite());
pge->SetDrawTarget(nullptr);
img.Decal()->Update();
}
void CollectionPoint::Update(PixelGameEngine*pge,Renderable&matrixImg){
pge->SetDrawTarget(img.Sprite());
for(int y=0;y<img.Sprite()->height;y++){
for(int x=0;x<img.Sprite()->width;x++){
Pixel col=originalCollectionPointImg->GetPixel(x,y);
if(col==WHITE){
pge->Draw(x,y,matrixImg.Sprite()->GetPixel(int(x+randomOffset.x),int(y+randomOffset.y)));
}
}
}
img.Decal()->Update();
pge->SetDrawTarget(nullptr);
}