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.
45 lines
1.1 KiB
45 lines
1.1 KiB
#include "gameDefines.h"
|
|
|
|
extern Meteos*game;
|
|
|
|
Board::Board(vi2d boardSize,float gravity,float spawnRate)
|
|
:boardSize(boardSize),gravity(gravity),spawnRate(spawnRate){
|
|
drawOffset={(float)game->ScreenWidth()/2-boardSize.x/2*12,(float)game->ScreenHeight()/2-boardSize.y/2*12};
|
|
yBottom=(boardSize.y-1)*12;
|
|
for (int i=0;i<boardSize.x;i++) {
|
|
cols.push_back(std::vector<Block>());
|
|
}
|
|
}
|
|
|
|
void Board::spawnBlock(int col){
|
|
BlockClump c=BlockClump();
|
|
c.addBlock(col);
|
|
if (game->coinFlip(game->gen)==0) {
|
|
if (col>0) {
|
|
c.addBlock(col-1);
|
|
}
|
|
}
|
|
if (game->coinFlip(game->gen)==0) {
|
|
if (col<boardSize.x-1) {
|
|
c.addBlock(col+1);
|
|
}
|
|
}
|
|
clumps.push_back(c);
|
|
}
|
|
|
|
std::vector<Block>&Board::getBlocks(int col){
|
|
return cols[col];
|
|
}
|
|
|
|
std::vector<BlockClump>&Board::getBlockClumps(){
|
|
return clumps;
|
|
}
|
|
|
|
void Board::removeClump(int ind){
|
|
BlockClump&c=clumps[ind];
|
|
for (Block b:c.getBlocks()){
|
|
cols[b.pos.x/12].push_back(b);
|
|
cols[b.pos.x/12][cols[b.pos.x/12].size()-1].pos=c.getBlockPosition(b);
|
|
}
|
|
clumps.erase(clumps.begin()+ind);
|
|
} |