generated from sigonasr2/CPlusPlusProjectTemplate
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.
37 lines
947 B
37 lines
947 B
#include "gameDefines.h"
|
|
|
|
std::vector<Block>&BlockClump::getBlocks(){
|
|
return blocks;
|
|
}
|
|
|
|
void BlockClump::addBlock(int col,BlockColor color){
|
|
blocks.push_back(Block({(float)col*12,0},color));
|
|
}
|
|
|
|
void BlockClump::addBlock(int col,int row,BlockColor color){
|
|
blocks.push_back(Block({(float)col*12,(float)row*12},color));
|
|
}
|
|
|
|
void BlockClump::addBlock(vf2d offset,BlockColor color){
|
|
blocks.push_back(Block(offset,color));
|
|
}
|
|
|
|
void BlockClump::addBlockOnTopOf(int col,BlockColor color,int defaultY){
|
|
int highestY=999999;
|
|
for (Block&b:blocks) {
|
|
if (b.pos.x/12==col&&b.pos.y<=highestY) {
|
|
highestY=b.pos.y;
|
|
}
|
|
}
|
|
addBlock(col,(highestY==999999)?defaultY/12:highestY/12-1,color);
|
|
}
|
|
|
|
vf2d BlockClump::getBlockPosition(Block&b){
|
|
return {b.pos.x,b.pos.y+y};
|
|
}
|
|
|
|
void BlockClump::sortBlocks(){
|
|
std::sort(blocks.begin(),blocks.end(),[](Block&b1,Block&b2){
|
|
return b1.pos.y>b2.pos.y;
|
|
});
|
|
} |