Made block snapping for matching more lenient

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent a522d1b660
commit 4bd417871f
  1. 16
      Board.cpp
  2. BIN
      C++ProjectTemplate
  3. 16
      main.cpp

@ -21,16 +21,16 @@ maxWarningLevel(maxWarningLevel){
/*BlockClump newClump; /*BlockClump newClump;
BlockClump newClump2; BlockClump newClump2;
newClump.addBlock(2,0,BlockColor::WHITE); newClump.addBlock(2,0,BlockColor::WHITE);
newClump.addBlock(1,0,BlockColor::BLUE); newClump.addBlock(1,0,BlockColor::WHITE);
newClump.addBlock(0,0,BlockColor::GREEN); newClump.addBlock(0,0,BlockColor::WHITE);
newClump.addBlock(2,-1,BlockColor::RED); newClump.addBlock(2,-1,BlockColor::RED);
newClump.addBlock(3,-1,BlockColor::LIGHT); newClump.addBlock(3,-1,BlockColor::RED);
newClump2.addBlock(4,0,BlockColor::DARK); newClump2.addBlock(5,0,BlockColor::WHITE);
newClump2.addBlock(5,0,BlockColor::SOUL); newClump2.addBlock(6,0,BlockColor::WHITE);
newClump2.addBlock(6,0,BlockColor::TIME); newClump2.addBlock(7,0,BlockColor::WHITE);
newClump2.addBlock(7,0,BlockColor::BLUE); cols[4].push_back({{4*12,144},BlockColor::RED});
newClump2.addBlock(4,-1,BlockColor::GREEN);
newClump2.addBlock(5,-1,BlockColor::RED); newClump2.addBlock(5,-1,BlockColor::RED);
newClump2.addBlock(6,-1,BlockColor::RED);
newClump.y=100; newClump.y=100;
newClump2.y=100; newClump2.y=100;
clumps.push_back(newClump); clumps.push_back(newClump);

Binary file not shown.

@ -561,7 +561,7 @@ void Meteos::matchGroundedBlocks(){
if (i+checkX<gameBoard.boardSize.x) { if (i+checkX<gameBoard.boardSize.x) {
for (int k=0;k<gameBoard.getBlocks(i+checkX).size();k++){ for (int k=0;k<gameBoard.getBlocks(i+checkX).size();k++){
Block&b2=gameBoard.getBlocks(i+checkX)[k]; Block&b2=gameBoard.getBlocks(i+checkX)[k];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&b2.pos.y==checkY) { if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&std::abs(b2.pos.y-checkY)<0.2) {
found=true; found=true;
tempMatchIDsX.push_back({(int)(i+checkX),k}); tempMatchIDsX.push_back({(int)(i+checkX),k});
checkX++; checkX++;
@ -573,7 +573,7 @@ void Meteos::matchGroundedBlocks(){
if (c.landTime>0) { if (c.landTime>0) {
for (int l=0;l<c.getBlocks().size();l++){ for (int l=0;l<c.getBlocks().size();l++){
Block&b2=c.getBlocks()[l]; Block&b2=c.getBlocks()[l];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&c.getBlockPosition(b2).y==checkY){ if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&std::abs(c.getBlockPosition(b2).y-checkY)<0.2){
found=true; found=true;
tempMatchIDsX.push_back({(int)(b2.pos.x/12),l,k}); tempMatchIDsX.push_back({(int)(b2.pos.x/12),l,k});
checkX++; checkX++;
@ -593,7 +593,7 @@ void Meteos::matchGroundedBlocks(){
if (i+checkX>=0) { if (i+checkX>=0) {
for (int k=0;k<gameBoard.getBlocks(i+checkX).size();k++){ for (int k=0;k<gameBoard.getBlocks(i+checkX).size();k++){
Block&b2=gameBoard.getBlocks(i+checkX)[k]; Block&b2=gameBoard.getBlocks(i+checkX)[k];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&b2.pos.y==checkY) { if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&std::abs(b2.pos.y-checkY)<0.2) {
found=true; found=true;
tempMatchIDsX.push_back({(int)(i+checkX),k}); tempMatchIDsX.push_back({(int)(i+checkX),k});
checkX--; checkX--;
@ -605,7 +605,7 @@ void Meteos::matchGroundedBlocks(){
if (c.landTime>0) { if (c.landTime>0) {
for (int l=0;l<c.getBlocks().size();l++){ for (int l=0;l<c.getBlocks().size();l++){
Block&b2=c.getBlocks()[l]; Block&b2=c.getBlocks()[l];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&c.getBlockPosition(b2).y==checkY){ if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==b.pos.x+checkX*12&&std::abs(c.getBlockPosition(b2).y-checkY)<0.2){
found=true; found=true;
tempMatchIDsX.push_back({(int)(b2.pos.x/12),l,k}); tempMatchIDsX.push_back({(int)(b2.pos.x/12),l,k});
checkX--; checkX--;
@ -625,7 +625,7 @@ void Meteos::matchGroundedBlocks(){
for (int k=0;k<gameBoard.getBlocks(i).size();k++){ for (int k=0;k<gameBoard.getBlocks(i).size();k++){
Block&b2=gameBoard.getBlocks(i)[k]; Block&b2=gameBoard.getBlocks(i)[k];
if (j==k)continue; if (j==k)continue;
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&std::abs(b2.pos.y-checkY)<0.2) {
found=true; found=true;
checkY-=12; checkY-=12;
tempMatchIDsY.push_back({i,k}); tempMatchIDsY.push_back({i,k});
@ -637,7 +637,7 @@ void Meteos::matchGroundedBlocks(){
if (c.landTime>0) { if (c.landTime>0) {
for (int l=0;l<c.getBlocks().size();l++){ for (int l=0;l<c.getBlocks().size();l++){
Block&b2=c.getBlocks()[l]; Block&b2=c.getBlocks()[l];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&c.getBlockPosition(b2).x==checkX&&c.getBlockPosition(b2).y==checkY){ if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&c.getBlockPosition(b2).x==checkX&&std::abs(c.getBlockPosition(b2).y-checkY)<0.2){
found=true; found=true;
checkY-=12; checkY-=12;
tempMatchIDsY.push_back({(int)(b2.pos.x/12),l,k}); tempMatchIDsY.push_back({(int)(b2.pos.x/12),l,k});
@ -656,7 +656,7 @@ void Meteos::matchGroundedBlocks(){
for (int k=0;k<gameBoard.getBlocks(i).size();k++){ for (int k=0;k<gameBoard.getBlocks(i).size();k++){
Block&b2=gameBoard.getBlocks(i)[k]; Block&b2=gameBoard.getBlocks(i)[k];
if (j==k)continue; if (j==k)continue;
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&std::abs(b2.pos.y-checkY)<0.2) {
found=true; found=true;
checkY+=12; checkY+=12;
tempMatchIDsY.push_back({i,k}); tempMatchIDsY.push_back({i,k});
@ -668,7 +668,7 @@ void Meteos::matchGroundedBlocks(){
if (c.landTime>0) { if (c.landTime>0) {
for (int l=0;l<c.getBlocks().size();l++){ for (int l=0;l<c.getBlocks().size();l++){
Block&b2=c.getBlocks()[l]; Block&b2=c.getBlocks()[l];
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&c.getBlockPosition(b2).x==checkX&&c.getBlockPosition(b2).y==checkY){ if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&c.getBlockPosition(b2).x==checkX&&std::abs(c.getBlockPosition(b2).y-checkY)<0.2){
found=true; found=true;
checkY+=12; checkY+=12;
tempMatchIDsY.push_back({(int)(b2.pos.x/12),l,k}); tempMatchIDsY.push_back({(int)(b2.pos.x/12),l,k});

Loading…
Cancel
Save