what i;ve found is .... WHAT THE !!!!!! !
i just realized my code was working in debug mode with no problems and shape draw function returned true even if it didn't hit anything to say it's true,
also that it returns false in release mode even tough it didn't hit any return false statement.
in the "if statement" that was checking for shape collision with solid blocks i forgot to put a return true statement if it evaluated as true, and only had return false statement if evaluated as false,
this was the original code
Code: Select all
bool Game::DrawShape(int x,int y,int lx,int ly,shape sp,SQRState state)
{
if(!GameOver()) //chekcking if game is not over...
{
int ymax=ShapeXYpos(x,y,SP,8);
int minX=ShapeXYpos(kx,ky,SP,1); //calling ShapeXYpos to get the min x and max x coordinates in relation ship with kx,ky ,shape model and shape facing
int maxX=ShapeXYpos(kx,ky,SP,2); //getting the y value of the bottom most block of current shape;
if
(CollisionCheck(x,y,SP)&&ymax<18) //square check statement,cheks if the shape did not hit any other shape or the bottom of square table,i have left and right movement cheks so it cannot tough other shapes from the side
{
SetSquareState(ShapeXYpos(kx,ky,SP,1),ShapeXYpos(kx,ky,SP,5),state); //setting normal square states if check pass
SetSquareState(ShapeXYpos(kx,ky,SP,2),ShapeXYpos(kx,ky,SP,6),state);
SetSquareState(ShapeXYpos(kx,ky,SP,3),ShapeXYpos(kx,ky,SP,7),state);
SetSquareState(ShapeXYpos(kx,ky,SP,4),ShapeXYpos(kx,ky,SP,8),state);
}
else
{
SetSquareSolidState(ShapeXYpos(lx,ly,SP,1),ShapeXYpos(lx,ly,SP,5),state); //setting solid square shape to last x,y position since new position will be colliding whith a solid block or bottom of square table
SetSquareSolidState(ShapeXYpos(lx,ly,SP,2),ShapeXYpos(lx,ly,SP,6),state);
SetSquareSolidState(ShapeXYpos(lx,ly,SP,3),ShapeXYpos(lx,ly,SP,7),state);
SetSquareSolidState(ShapeXYpos(lx,ly,SP,4),ShapeXYpos(lx,ly,SP,8),state);
return false; //it allso returns false for the update shape function to know it needs to generate new shape
}
}
}
not sure exactly if this is an intended behavior to point us to bugs in run time or is just different default return values choosen by the release mode settings.
i may be wrong with what i've said here but since i found it i think i deserve an explanation
also (if possible) make sure to mention it in some future lesson ,i think u already said about type functions and that we must have a return statement ,altough i think some need to also know what happends if u miss it