generated from sigonasr2/CPlusPlusProjectTemplate
Add debug checks
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
cc284ef32c
commit
09ee429e0f
Binary file not shown.
23
main.cpp
23
main.cpp
@ -68,8 +68,16 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
|
|
||||||
if (c2.getBlockPosition(b2).y>c.getBlockPosition(b3).y) {
|
if (c2.getBlockPosition(b2).y>c.getBlockPosition(b3).y) {
|
||||||
c.y-=12-(c2.getBlockPosition(b2).y-c.getBlockPosition(b3).y);
|
c.y-=12-(c2.getBlockPosition(b2).y-c.getBlockPosition(b3).y);
|
||||||
|
if (fmod(c2.y-c.y,12)!=0){
|
||||||
|
std::cout<<"Difference is not equal to 12!! Value:"<<c2.y-c.y<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
c2.y-=12-(c.getBlockPosition(b3).y-c2.getBlockPosition(b2).y);
|
c2.y-=12-(c.getBlockPosition(b3).y-c2.getBlockPosition(b2).y);
|
||||||
|
if (fmod(c2.y-c.y,12)!=0){
|
||||||
|
std::cout<<"Difference is not equal to 12!! Value:"<<c.y-c2.y<<std::endl;
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size());
|
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size());
|
||||||
int blockCount=c.getBlocks().size();
|
int blockCount=c.getBlocks().size();
|
||||||
@ -82,6 +90,17 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
std::cout<<"Block size is: "<<c.getBlocks().size()<<" but expected "<<blockCount+c2.getBlocks().size()<<std::endl;
|
std::cout<<"Block size is: "<<c.getBlocks().size()<<" but expected "<<blockCount+c2.getBlocks().size()<<std::endl;
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
bool overlappingBlocks=false;
|
||||||
|
for (int m=0;m<c.getBlocks().size();m++){
|
||||||
|
for (int n=0;n<c.getBlocks().size();n++){
|
||||||
|
if(m==n)continue;
|
||||||
|
if (c.getBlocks()[m].pos==c.getBlocks()[n].pos){
|
||||||
|
std::cout<<"Block overlapping detected at "<<c.getBlocks()[m].pos<<"!"<<std::endl;
|
||||||
|
overlappingBlocks=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(!overlappingBlocks);
|
||||||
if (c.vspeed>0) {
|
if (c.vspeed>0) {
|
||||||
c.vspeed/=4;
|
c.vspeed/=4;
|
||||||
}
|
}
|
||||||
@ -440,7 +459,7 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
if (info.c!=-1){
|
if (info.c!=-1){
|
||||||
Block&b=gameBoard.getBlockClumps()[info.c].getBlocks()[info.ind];
|
Block&b=gameBoard.getBlockClumps()[info.c].getBlocks()[info.ind];
|
||||||
for (Block&b2:gameBoard.getBlockClumps()[info.c].getBlocks()){
|
for (Block&b2:gameBoard.getBlockClumps()[info.c].getBlocks()){
|
||||||
if (!b2.markedForRemoval&&gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y<=gameBoard.getBlockClumps()[info.c].getBlockPosition(b).y){
|
if (!b2.markedForRemoval&&b.pos.x==b2.pos.x&&gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y<=gameBoard.getBlockClumps()[info.c].getBlockPosition(b).y){
|
||||||
c.addBlock(b.pos.x/12,(gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y-baseBlockPos)/12,b2.col);
|
c.addBlock(b.pos.x/12,(gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y-baseBlockPos)/12,b2.col);
|
||||||
b2.markedForRemoval=true;
|
b2.markedForRemoval=true;
|
||||||
}
|
}
|
||||||
@ -478,11 +497,11 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
for (int i=0;i<gameBoard.boardSize.x;i++){
|
for (int i=0;i<gameBoard.boardSize.x;i++){
|
||||||
for (int y=0;y<gameBoard.getBlocks(i).size();y++){
|
for (int y=0;y<gameBoard.getBlocks(i).size();y++){
|
||||||
Block&b=gameBoard.getBlocks(i)[y];
|
Block&b=gameBoard.getBlocks(i)[y];
|
||||||
|
b.addedToLaunchList=false;
|
||||||
if (b.markedForRemoval){
|
if (b.markedForRemoval){
|
||||||
gameBoard.removeBlock(i,y--);
|
gameBoard.removeBlock(i,y--);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
b.addedToLaunchList=false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Invalidate the selected block if something is strange about it.
|
//Invalidate the selected block if something is strange about it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user