clang-format #39

Merged
MartinFouilleul merged 6 commits from clang-format into main 2023-08-18 15:59:41 +00:00
1 changed files with 16 additions and 30 deletions
Showing only changes of commit c99217920f - Show all commits

View File

@ -334,17 +334,15 @@ int checkCollision(mp_rect block)
f32 blockx2 = block.x + block.w; f32 blockx2 = block.x + block.w;
f32 blocky2 = block.y + block.h; f32 blocky2 = block.y + block.h;
if( if(ballx2 < block.x || blockx2 < ball.x || bally2 < block.y || blocky2 < ball.y)
ballx2 < block.x || blockx2 < ball.x || bally2 < block.y || blocky2 < ball.y)
{ {
// Ball is fully outside block // Ball is fully outside block
return 0; return 0;
} }
// if ( // if ((block.x <= ball.x && ballx2 <= blockx2)
// (block.x <= ball.x && ballx2 <= blockx2) // && (block.y <= ball.y && bally2 <= blocky2))
// && (block.y <= ball.y && bally2 <= blocky2) // {
// ) {
// // Ball is fully inside block; do not consider as a collision // // Ball is fully inside block; do not consider as a collision
// return 0; // return 0;
// } // }
@ -367,22 +365,19 @@ int checkCollision(mp_rect block)
if(velocity.x > 0) if(velocity.x > 0)
{ {
// Ball's top right corner // Ball's top right corner
if( if(ballCenter.x <= block.x && block.x <= ballx2 && ballCenter.y <= block.y && block.y <= bally2)
ballCenter.x <= block.x && block.x <= ballx2 && ballCenter.y <= block.y && block.y <= bally2)
{ {
return 2; return 2;
} }
// Ball's bottom right corner // Ball's bottom right corner
if( if(ballCenter.x <= block.x && block.x <= ballx2 && ball.y <= blocky2 && blocky2 <= ballCenter.y)
ballCenter.x <= block.x && block.x <= ballx2 && ball.y <= blocky2 && blocky2 <= ballCenter.y)
{ {
return 4; return 4;
} }
// Ball's right edge // Ball's right edge
if( if(ballCenter.x <= block.x && block.x <= ballx2)
ballCenter.x <= block.x && block.x <= ballx2)
{ {
return 3; return 3;
} }
@ -392,22 +387,19 @@ int checkCollision(mp_rect block)
if(velocity.y > 0) if(velocity.y > 0)
{ {
// Ball's top left corner // Ball's top left corner
if( if(ball.x <= blockx2 && blockx2 <= ballCenter.x && ballCenter.y <= block.y && block.y <= bally2)
ball.x <= blockx2 && blockx2 <= ballCenter.x && ballCenter.y <= block.y && block.y <= bally2)
{ {
return 8; return 8;
} }
// Ball's top right corner // Ball's top right corner
if( if(ballCenter.x <= block.x && block.x <= ballx2 && ballCenter.y <= block.y && block.y <= bally2)
ballCenter.x <= block.x && block.x <= ballx2 && ballCenter.y <= block.y && block.y <= bally2)
{ {
return 2; return 2;
} }
// Ball's top edge // Ball's top edge
if( if(ballCenter.y <= block.y && block.y <= bally2)
ballCenter.y <= block.y && block.y <= bally2)
{ {
return 1; return 1;
} }
@ -417,22 +409,19 @@ int checkCollision(mp_rect block)
if(velocity.x < 0) if(velocity.x < 0)
{ {
// Ball's bottom left corner // Ball's bottom left corner
if( if(ball.x <= blockx2 && blockx2 <= ballCenter.x && ball.y <= blocky2 && blocky2 <= ballCenter.y)
ball.x <= blockx2 && blockx2 <= ballCenter.x && ball.y <= blocky2 && blocky2 <= ballCenter.y)
{ {
return 6; return 6;
} }
// Ball's top left corner // Ball's top left corner
if( if(ball.x <= blockx2 && blockx2 <= ballCenter.x && ballCenter.y <= block.y && block.y <= bally2)
ball.x <= blockx2 && blockx2 <= ballCenter.x && ballCenter.y <= block.y && block.y <= bally2)
{ {
return 8; return 8;
} }
// Ball's left edge // Ball's left edge
if( if(ball.x <= blockx2 && blockx2 <= ballCenter.x)
ball.x <= blockx2 && blockx2 <= ballCenter.x)
{ {
return 7; return 7;
} }
@ -442,22 +431,19 @@ int checkCollision(mp_rect block)
if(velocity.y < 0) if(velocity.y < 0)
{ {
// Ball's bottom right corner // Ball's bottom right corner
if( if(ballCenter.x <= block.x && block.x <= ballx2 && ball.y <= blocky2 && blocky2 <= ballCenter.y)
ballCenter.x <= block.x && block.x <= ballx2 && ball.y <= blocky2 && blocky2 <= ballCenter.y)
{ {
return 4; return 4;
} }
// Ball's bottom left corner // Ball's bottom left corner
if( if(ball.x <= blockx2 && blockx2 <= ballCenter.x && ball.y <= blocky2 && blocky2 <= ballCenter.y)
ball.x <= blockx2 && blockx2 <= ballCenter.x && ball.y <= blocky2 && blocky2 <= ballCenter.y)
{ {
return 6; return 6;
} }
// Ball's bottom edge // Ball's bottom edge
if( if(ball.y <= blocky2 && blocky2 <= ballCenter.y)
ball.y <= blocky2 && blocky2 <= ballCenter.y)
{ {
return 5; return 5;
} }