Refactor removing extra space and add break line for { (#5533)
Co-authored-by: maiconpintoabreu <maicon@thinkpad02.exads.com>
This commit is contained in:
parent
d4f636151b
commit
f43e049444
18 changed files with 35 additions and 23 deletions
|
|
@ -139,14 +139,14 @@ int main(void)
|
|||
Ball *ball = &balls[i];
|
||||
|
||||
// The ball is not grabbed
|
||||
if (!ball->grabbed)
|
||||
if (!ball->grabbed)
|
||||
{
|
||||
// Ball repositioning using the velocity
|
||||
ball->pos.x += ball->vel.x * delta;
|
||||
ball->pos.y += ball->vel.y * delta;
|
||||
|
||||
// Does the ball hit the screen right boundary?
|
||||
if ((ball->pos.x + ball->radius) >= screenWidth)
|
||||
if ((ball->pos.x + ball->radius) >= screenWidth)
|
||||
{
|
||||
ball->pos.x = screenWidth - ball->radius; // Ball repositioning
|
||||
ball->vel.x = -ball->vel.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit
|
||||
|
|
@ -159,12 +159,12 @@ int main(void)
|
|||
}
|
||||
|
||||
// The same for y axis
|
||||
if ((ball->pos.y + ball->radius) >= screenHeight)
|
||||
if ((ball->pos.y + ball->radius) >= screenHeight)
|
||||
{
|
||||
ball->pos.y = screenHeight - ball->radius;
|
||||
ball->vel.y = -ball->vel.y*ball->elasticity;
|
||||
}
|
||||
else if ((ball->pos.y - ball->radius) <= 0)
|
||||
else if ((ball->pos.y - ball->radius) <= 0)
|
||||
{
|
||||
ball->pos.y = ball->radius;
|
||||
ball->vel.y = -ball->vel.y*ball->elasticity;
|
||||
|
|
|
|||
Loading…
Reference in a new issue