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.
72 lines
2.1 KiB
72 lines
2.1 KiB
#ifndef BOARD_H
|
|
#define BOARD_H
|
|
#include "pixelGameEngine.h"
|
|
|
|
class Block;
|
|
class BlockClump;
|
|
|
|
enum class BlockColor;
|
|
|
|
class ColorDistributor{
|
|
std::array<std::pair<int,int>,10>rangeTable;
|
|
int maxRange=0;
|
|
std::uniform_int_distribution<>range;
|
|
public:
|
|
ColorDistributor(std::array<int,10>colorRates){
|
|
int sum=0;
|
|
for (int i=0;i<colorRates.size();i++) {
|
|
if (colorRates[i]>0) {
|
|
rangeTable[i]={sum,sum+colorRates[i]};
|
|
sum+=colorRates[i];
|
|
maxRange=sum;
|
|
} else {
|
|
rangeTable[i]={-1,-1};
|
|
}
|
|
}
|
|
range=std::uniform_int_distribution<>(0, maxRange);
|
|
}
|
|
BlockColor getRandomColor();
|
|
};
|
|
|
|
struct SelectedBlockData{
|
|
int col=-1;
|
|
int ind=-1;
|
|
int c=-1;
|
|
};
|
|
|
|
class Board{
|
|
std::vector<std::vector<Block>> cols;
|
|
std::vector<BlockClump> clumps;
|
|
public:
|
|
ColorDistributor colorHandler;
|
|
float yBottom;
|
|
Decal*tileset;
|
|
vf2d drawOffset;
|
|
vi2d boardSize;
|
|
float gravity;
|
|
float maxGravity;
|
|
float comboGravity;
|
|
float comboMaxGravity;
|
|
float spawnRate;
|
|
float blockWeight; //How much this dampens the launch speeds.
|
|
std::vector<float> launchSpd;
|
|
float launchTime; //How much time a stack rises before beginning descent.
|
|
float landTime;
|
|
SelectedBlockData selectedBlock;
|
|
int warningLevel=0;
|
|
int maxWarningLevel=0;
|
|
std::vector<float> warningFlashingLevel;
|
|
Board();
|
|
Board(vi2d boardSize,float blockWeight,float gravity,float maxGravity,float launchedGravity,float launchedMaxGravity,std::vector<float> launchSpd,float launchTime,float landTime,float spawnRate,std::array<int,10> colorRates,
|
|
int maxWarningLevel,Renderable&tileset);
|
|
void spawnBlock(int col);
|
|
void addClump(BlockClump&c);
|
|
std::vector<Block>&getBlocks(int col);
|
|
std::vector<BlockClump>&getBlockClumps();
|
|
void convertClump(int ind);
|
|
void removeClump(int ind);
|
|
void removeBlock(int col,int ind);
|
|
void assignRandomColor(Block&b);
|
|
Block&getBlock(SelectedBlockData&blockData);
|
|
};
|
|
#endif |